Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A. Requirements Use a Java IDE, such as Eclipse, for your assignment. Submit the project folder using your student ID name, with all your java
A. Requirements Use a Java IDE, such as Eclipse, for your assignment. Submit the "project" folder using your student ID name, with all your java source files stored under the corresponding packages (see "Eclipse Export.pdf' in Canvas for project export details) B. Description The assignment goal is to program a simple game winner consisting of an arbitrary number of players and staff competing against each other. The program extends Assignment 1. Each player and staff is assigned a unique numerical id and a random value between 0 and 1. The player or staff with the highest numerical value wins B.1 Person. Player, and Staff Classes Design three java classes, Person, Player, and Staff, stored in the package "person": Player and Staff are both subclasses of the superclass Person . A private int data field named id stores the general Person identifier (default 0) . A private int data field named playerld stores the Player identifier (default 0) . A private int data field named staffld stores the Staff identifier (default 0) . A private double data field named val stores a random Person value (default 0 . A static totalPersonNum stores the total number of Person objects. . A static totalPlayerNum stores the total number of Player objects . A static totalStaffNum stores the total number of Staff objects A printVal method prints the id and yal of each Person object System.out.println (.. Person Id '' + 1d + " from a total of " + totalPersonNum"Value" val); A printVal method in the Player class overrides the printVal method in the Person class as follows: System. out.println(" Player Id .. + 1d + from a total of + totalPlayerNum); A printVal method in the Staff class overrides the printVal method in the Person class as follows: System.out.println(" Staff Id " + id " from a total of "+ totalStaffNum); . You can assign additional methods as necessary B.2 Winner Class Design a Winner class, stored in the package "game": The main Java method containing the following code public static void main(String [] args) t . Person [ personArray new Person [numPerson] Winner w - new Winner); W.init game (personArray); Person pw.find_person_winner(personArray); if (p!-null) t System.out.println("Person Winner is: "); p.printVal); Player player w.find player_winner(personArray); if (playernull) System.out.println("Player Winner is: "); player.printVal); Staff staff - w.find staff winner(personArray): if (staffnull) System.out.println("Staff Winner is: "); staff.printValO; . A method called init game where an arbitrary number of players and staff, adding up together to numPerson, gets instantiated with a sequential id number for all persons, a playerId and a staffId depending on whether they are players or staff, and a random value between 0 and 1. The person array with all their ids and values needs to be printed . A method called find person_winner where random values assigned to each person are compared and the person, independent on whether it is a player or staff, is the winner. Printout should include corresponding person winner id and value . A method called find player_winner where random values assigned to each player are compared and the player with the largest value is the winner. Printout should include corresponding player winner id and value A method called find staff winner where random values assigned to each staff are compared and the staff with the largest value is the winner. Printout should include corresponding staff winner id and value . The program output should be as follows
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started