Assignment #4 (to demonstrate polymorphism via the sport class hierarchy)
-
Athlete class (see Athlete.java)
-
<Sport> class (e.g., Wrestling class - see Wrestling.java)
[Assignment #4]
-
Inputs class (see Inputs.java)
[Assignment #4-2]
-
readString method
-
readInt method (see Input.java
from class web page)
-
readDouble method
-
Menu class (see Menu.java - will be available on Wednesday, March 24th)
-
class constants
-
ADD_CHOICE, FIND_CHOICE, QUIT_CHOICE, INVALID_CHOICE
-
BASEBALL_ATHLETE, BASKETBALL_ATHLETE, BOXING_ATHLETE, FOOTBALL_ATHLETE,
SOCCER_ATHLETE, WRESTLING_CHOICE, INVALID_ATHLETE, MIN_ATHLETE, MAX_ATHLETE
(now MIN_ATHLETE == BASEBALL_ATHLETE and MAX_ATHLETE == WRESTLING_ATHLETE)
-
instance character fields
-
choice (used to store main menu choice - initialize to INVALID_CHOICE)
-
athlete (used to store add menu choice - initialize to INVALID_ATHLETE)
-
instance methods
-
mainMenu (show menu and read choice - check for invalid) and getChoice
(accessor)
-
<two blank lines>
-
Athlete Menu
-
<blank line>
-
a - add an athlete
-
f - find top athlete
-
q - quit
-
<blank line>
-
Choice?<space>
-
addMenu (show menu and read choice - check for invalid) and getAthlete
(accessor)
-
<two blank lines>
-
Add Athlete Menu
-
<blank line>
-
1 - baseball
-
2 - basketball
-
3 - boxing
-
4 - football
-
5 - soccer
-
6 - wrestling
-
<blank line>
-
Athlete?<space>
-
TopAthlete class (see TopAthlete.java - will be available on Friday, March
26)
-
class constant (MAX_ATHLETES with a value of 20)
-
class method (main)
-
local character variable called choice
-
local Menu object called menu
-
local Athlete array (MAX_ATHLETES elements) object called athletes
-
local integer variable called athleteCount
-
main menu loop (while choice different than quit choice)
-
add an athlete choice
-
local character variable called athlete
-
add menu call
-
decisions for all six athletes (call get<Sport>Athlete method) and invalid
choice
-
"Maximum athletes of <MAX_ATHLETES> already entered"
message
-
"Invalid add menu choice" message
-
find top athlete choice
-
loop to search athletes array for first top value
-
local integer variables called topValue, topIndex, index, and nextValue
-
"<name> has the top value of <value>" message
-
"No athletes entered" message when athleteCount is zero
-
invalid choice
-
"Invalid main menu choice"
-
add get<Sport>Athlete method to <Sport> class (Louis' inquiry - should
it be static?) [Assignment #4-3]