} //IndexOf /// <summary> /// Searches the collection for the given year and returns the index. /// If the item is not found in the collection then an ArgumentException /// will be thrown /// </summary> /// <param name="intYear"> /// The year to search for /// </param> /// <returns> /// The index of the year /// </returns> /// <example> /// <code> /// CYearCollection coll = new CYearCollection(); /// CYear temp = new CYear(2004, new CEventCollection()); /// coll.Add(temp); /// int intIndex = coll.SearchYear(temp.Year); /// </code> /// </example> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 02/15/06 rrr N/A N/A Creation of class public int SearchYear(int intYear) { //Go through the collection checking for matches and return the index //when one is found for (int intIterate = 0; intIterate < InnerList.Count; intIterate++) { CYear objYear = (CYear)InnerList[intIterate]; if (objYear.Year == intYear) { return(intIterate); } } //If the item was not found then throw an error throw new ArgumentException("The given Year is not in the Collection", "int intYear"); } //SearchYear
} //this[] /// <summary> /// Adds a Year to the end of the YearCollection /// </summary> /// <param name="objToAdd"> /// The Year to be added /// </param> /// <returns> /// The zero base index of the Year added /// </returns> /// <example> /// <code> /// CYearCollection coll = new CYearCollection(); /// coll.Add(new CYear(2004, new CEventCollection())); /// </code> /// </example> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 02/15/06 rrr N/A N/A Creation of class public int Add(CYear objToAdd) { return(InnerList.Add(objToAdd)); } //Add
} //Add /// <summary> /// Adds a Year to the YearCollection at the given index /// </summary> /// <param name="intIndex"> /// Index to insert the Year into in the collection /// </param> /// <param name="objToAdd"> /// The Year to be added /// </param> /// <example> /// <code> /// CYearCollection coll = new CYearCollection(); /// coll.Insert(3, new CYear(2004, new CEventCollection())); /// </code> /// </example> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 02/15/06 rrr N/A N/A Creation of class public void Insert(int intIndex, CYear objToAdd) { InnerList.Insert(intIndex, objToAdd); } //Insert
} // CYear /// <summary> /// Used to be able to compare two CYear objects based on the year /// </summary> /// <param name="obj"> /// The year to compare to the current year /// </param> /// <returns> /// An int that represents the objects being equal, less than, or greater than /// </returns> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 02/15/06 rrr N/A N/A Creation of class public int CompareTo(object obj) { CYear objCompare = (CYear)obj; return(this.Year.CompareTo(objCompare.Year)); } // CompareTo