Part-1 Design
Explain how your design will be able to store the information of games, athletes and user predictions.
Ans – To store game data Hashmap is used. Its key is String, and it will store Game type. Its value is List of athletes. User predictions are stored in Driver class instance variable “predictWinnerName.”
Explain how your class hierarchy will forbid a user from creating a “generic” type of participant (i.e., not an athlete nor an official)
Ans- I have created abstract class “Participant” which stores common information of official and athlete. It stores name, age, and state. After that, I have created an Official class which inherits Participant class, and its additional variable is ID.
Similarly Athletes class inherits Participant class, and it has additional variable like – ID, Athletic Type, last game point, total points, completeTime.
Explain the process by which your program will maintain a game and give the correct score to athletes according to their performance.
Ans- To maintain game HashMap is used. For the correct score, I have added variable “totalPoints” that will store total score from the beginning. When any game is finished score is provided to first three winners and also according to that “TotalPoints” are getting updated.
Explain how a user prediction can be checked with the actual game results.
Ans- When the user starts a new game, we are asking to predict winner name. After that start game option is selected which generates a score of each athlete that are participants in-game and their result is sorted in ascending order. From that first three winners are taken, and first winner name is getting matched with predict name. If they are same, displaying the message that you are the winner.