Exemplo n.º 1
0
        /// <summary>
        /// Select a group of elements based on their periodic family
        /// </summary>
        /// <param name="family">The family to search for, from the AppEnum.Family enumerable</param>
        /// <returns>List of Element</returns>
        public IEnumerable <Element> SelectEachMember(AppEnum.Family family)
        {
            List <Element> searchResults = new List <Element>();

            //if there are no elements in the list
            if (!this.elements.Any())
            {
                //throw an exception
                throw new ArgumentException("EmptyList");
            }

            //otherwise, look through all the existing elements for any matches
            foreach (Element element in this.elements)
            {
                if (element.family == family)
                {
                    searchResults.Add(element);
                }
            }

            //if no matches were found, throw an exception
            if (!searchResults.Any())
            {
                throw new ArgumentException("FamilyMembersNotFound");
            }

            //otherwise, return the list of results
            return(searchResults);
        }
Exemplo n.º 2
0
 public Element(string _name, string _symbol, int _atomicNumber, double _atomicWeight, bool _isRadioactive, AppEnum.Family _family, int _period, int _atomicRadius)
 {
     name          = _name;
     symbol        = _symbol;
     atomicNumber  = _atomicNumber;
     atomicWeight  = _atomicWeight;
     isRadioactive = _isRadioactive;
     family        = _family;
     period        = _period;
     atomicRadius  = atomicRadius;
 }