/*
 * Category: This class stores information for one category in the
 *           triathalon.
 */

import java.util.*;
class Category {

	private String categoryName;	// name of the category
	private Vector athletes;		// Vector of Athlete objects

	// Static variable to keep track of the number of Category objects
	// that are created.  Each time a Category object is created, we
	// add one to this variable.  This variable determines the category
	// number for each Category, which is stored in the 'categoryNumber'
	// instance variable that is used to generate the athlete numbers.
	private static int categoryCounter = 0;

	// These two variables are used to generate the athlete numbers for
	// each new athlete registered in this category.
	private int categoryNumber;	// right most digit in athlete number is
								// the category number (0, 1, 2, etc).
	private int athleteCounter;	// remaining digits in athlete number count
								// each athlete registered (1, 2, 3, etc).

	/*
	 * Category constructor: Create a new category, with name, 'name'.
	 *    The constructor instantiates the Vector and initializes all
	 *    instance variables.
	 */
	public Category (String name) {
		// FILL IN THE BODY.



	}

	/*
	 * getName: return the name of the category.
	 */
	// FILL IN THE PROTOTYPE AND THE BODY.


	}

	/*
	 * addAthlete: Add athlete 'newAthlete' to the Vector of Athletes.
	 */
	public void addAthlete (Athlete newAthlete) {
		// FILL IN THE BODY.


	}

	/*
	 * deleteAthlete: Delete athlete with athlete number 'athleteNum'
	 *    from this category.  Note: do not worry about adjusting the
	 *    athleteCounter variable when athletes are deleted.
	 */
	public void deleteAthlete (int athleteNum) {
		// Examine each element in the Vector of athletes.  If an
		// element has an athlete number that matches the athlete
		// number passed to this method, delete this element.
		for (int i=0; i<athletes.size(); i++) {
			// FILL IN PART OF THE BODY.



		}
	}

	/*
	 * generateNumber: This method generates an athlete number for the
	 *    next athlete to be registered in this category.  This athlete
	 *    number is returned by this method.  The right most digit is
	 *    the category number ("0" for the first category created, "1"
	 *    for the next category, etc).  The digits on the left count
	 *    each athlete in this category ("1" for the first, "2" for the
	 *    second, etc).
	 */
	public int generateNumber () {
		String newNumber = "" + athleteCounter + categoryNumber;
		return Integer.parseInt(newNumber);
	}

	/*
	 * findAthlete: Searches in the Vector of athletes for the
	 *    athlete with name 'athleteName'.  If found, it returns
	 *    a reference to this Athlete object, otherwise it returns
	 *    null to indicate the athlete was not found (simply
	 *    use the statement "return null" when you determine
	 *    this athlete name does not exist in this category).
	 */
	public Athlete findAthlete (String athleteName) {

		// Check if each athlete element in the Vector contains
		// the name 'athleteName' that was passed to this method.
		// FILL IN PART OF THE BODY.




		// Athlete name was not found, so return null.  This is a way
		// to put an empty value in an object reference.
		return null;
	}

	/*
	 * findAthlete: Searches in the Vector of athletes for the
	 *    athlete with athlete number 'athleteNum'.  If found, it
	 *    returns a reference to this Athlete object, otherwise it
	 *    returns null to indicate the athlete was not found (simply
	 *    use the statement "return null;" when you determine
	 *    this athlete number does not exist in this category).
	 */
	// FILL IN THE PROTOTYPE AND THE BODY.
	public Athlete findAthlete (int athleteNum) {

		// Check if each athlete element in the Vector contains the
		// athlete number 'athleteNum' that was passed to this method.
		// FILL IN PART OF THE BODY.




		// Athlete number was not found, so return null.  This is a way
		// to put an empty value in an object reference.
		return null;
	}

	/*
	 * hasStarted: This method returns true if at least one athlete
	 *    in this category has started the race.  It returns false
	 *    otherwise.
	 */
	public boolean hasStarted () {
		// Go through each element in the vector.  If any one of these
		// athletes has started the race, then return true.
		for (int i=0; i<athletes.size(); i++) {
			if (((Athlete)athletes.elementAt(i)).hasStarted()) {
				return true;
			}
		}

		return false;	// No athletes have started
	}

	/*
	 * report: Print information for all athletes in this category.  For
	 *    each athlete in this category, print the category name, athlete
	 *    name, athlete number (#), swim time, run time, bike time, and
	 *    total accumulated time.  If an athlete does not have a time
	 *    recorded for an event, NA is printed for the missing times.
	 *    Calls a method in the Athlete class to get some information.
	 *    - Print a tab ("\t") between each value to improve alignment.
	 */
	public void report () {
		// FILL IN THE BODY.


	}

	/*
	 * toString: return all information stored in this class.
	 *    This method is used for testing only.
	 */
	public String toString () {
		// THIS METHOD IS OPTIONAL - COMPLETE IF DESIRED.
		return "";
	}
}
