Class Competition

java.lang.Object
  extended by Competition

public class Competition
extends Object

Creates and manages an array of objects of type MazeResult.

Version:
Summer 2014
Author:
Tina Comston

Field Summary
static int ALL
          Flag to signify ALL.
static int FEMALE
          Flag to signify FEMALE.
static int MALE
          Flag to signify MALE.
static int NOT_VACCINATED
          Flag to signify NOT_VACCINATED.
static int VACCINATED
          Flag to signify VACCINATED.
 
Constructor Summary
Competition(String inDesc)
          Constructor for objects of class Competition.
 
Method Summary
 void addMazeResult(MazeResult inMazeResult)
          add a MazeResult object to the array list.
 void deleteMazeResult(int inIndex)
          delete a MazeResult object from the array list.
 void deleteMazeResult(String inRFID)
          delete MazeResult object from the array list.
 int getCount()
          get the count of populated elements in the array list.
 String getDesc()
          get the competition description.
 MazeResult getMazeResult(int inIndex)
          get a MazeResult object from the array list.
 MazeResult getMazeResult(String inRFID)
          get a MazeResult object from the array list.
 double getRatAveTime(int inCategory)
          get the average ACTUAL time of rats for a given category.
 int getRatCount(int inCategory)
          get the count of rats for a given category.
 boolean isCategoryMatch(int inCategory, Rat inRat)
          determine if the category matches condition.
 void setDesc(String inDesc)
          set the competition description.
 void sortByTime(char inDirection)
          Sort the array list by time, direction indicated by the explicit parameter.
 String toString()
          get a formatted string with information about a competition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

public static final int ALL
Flag to signify ALL.

See Also:
Constant Field Values

FEMALE

public static final int FEMALE
Flag to signify FEMALE.

See Also:
Constant Field Values

MALE

public static final int MALE
Flag to signify MALE.

See Also:
Constant Field Values

NOT_VACCINATED

public static final int NOT_VACCINATED
Flag to signify NOT_VACCINATED.

See Also:
Constant Field Values

VACCINATED

public static final int VACCINATED
Flag to signify VACCINATED.

See Also:
Constant Field Values
Constructor Detail

Competition

public Competition(String inDesc)
Constructor for objects of class Competition.

Parameters:
inDesc - The competition description.
Method Detail

addMazeResult

public void addMazeResult(MazeResult inMazeResult)
add a MazeResult object to the array list.

Parameters:
inMazeResult - The MazeResult object.

deleteMazeResult

public void deleteMazeResult(int inIndex)
delete a MazeResult object from the array list.

Parameters:
inIndex - The array list index position of the requested object.

deleteMazeResult

public void deleteMazeResult(String inRFID)
delete MazeResult object from the array list.

Parameters:
inRFID - The Rat RFID in the object to delete.

getCount

public int getCount()
get the count of populated elements in the array list.

Returns:
int The count of elements.

getDesc

public String getDesc()
get the competition description.

Returns:
String The competition description.

getMazeResult

public MazeResult getMazeResult(int inIndex)
get a MazeResult object from the array list.

Parameters:
inIndex - The index position of the requested object.
Returns:
MazeResult The MazeResult object from the array list, returns null if index not valid.

getMazeResult

public MazeResult getMazeResult(String inRFID)
get a MazeResult object from the array list.

Parameters:
inRFID - The Rats RFID in the requested object.
Returns:
MazeResult The MazeResult object from the array list, if not found returns null.

getRatAveTime

public double getRatAveTime(int inCategory)
get the average ACTUAL time of rats for a given category.

Parameters:
inCategory - Numeric value representing a race category.
Returns:
double The average time in maze in seconds.

getRatCount

public int getRatCount(int inCategory)
get the count of rats for a given category.

Parameters:
inCategory - Numeric value representing a rat category.
Returns:
int The count of rats.

isCategoryMatch

public boolean isCategoryMatch(int inCategory,
                               Rat inRat)
determine if the category matches condition.

Parameters:
inCategory - Numeric value representing a result category.
inRat - Rat object with associated attributes.
Returns:
boolean Boolean result of category check.

setDesc

public void setDesc(String inDesc)
set the competition description.

Parameters:
inDesc - The competition description.

sortByTime

public void sortByTime(char inDirection)
Sort the array list by time, direction indicated by the explicit parameter. Use a selection, insertion or bubble sort.

Parameters:
inDirection - A - ascending (shortest to longest) D - descending (longest to shortest) For an invalid sort direction, anything other than A or D do nothing, no sort. This method is based on the bblSort3 method presented in Module 11.

toString

public String toString()
get a formatted string with information about a competition.

Overrides:
toString in class Object
Returns:
String String with information about a competition.