Question
This java assignment will give you practice with classes, methods, and arrays. Part 1: Player Class Write a class named Player that stores a players
This java assignment will give you practice with classes, methods, and arrays.
Part 1: Player Class Write a class named Player that stores a players name and the players high score. A player is described by: players name players high score In your class, include: instance data variables two constructors getters and setters include appropriate value checks when applicable a toString method Part 2: PlayersList Class Write a class that manages a list of up to 10 players and their high scores. Create a single array of type Player that stores the players names and scores. In your class, include: a single array of type Player to hold player name and score. a constructor Your class should support the following features: Add a new player and score (up to 10 players). method header: public void addPlayer() Print all the players names and their scores to the screen. method header: public void printPlayers() Allow the user to enter a players name and output that players score or a message if that players name has not been entered. method header: public void lookupPlayer() Notes You can include additional instance data variables if it is helpful. If you include additional variables, include additional getters and setters as appropriate. I have provided a driver program ScoreManagementSystem.java you can use to test your code and sample output, of which yours should be the exact same.
//SAMPLE RUN
Score Management System Choose: A)dd new player P)rint all players L)ookup a player's score Q)uit A Enter name: Alexander Enter score: 300 Score Management System Choose: A)dd new player P)rint all players L)ookup a player's score Q)uit A Enter name: Michael Enter score: 200 Score Management System Choose: A)dd new player P)rint all players L)ookup a player's score Q)uit P Score Name 300 Alexander 200 Michael Score Management System Choose: A)dd new player P)rint all players L)ookup a player's score Q)uit L Enter name to look up. George Name not found.
Score Management System Choose: A)dd new player P)rint all players L)ookup a player's score Q)uit P Score Name 300 Alexander 200 Michael Score Management System Choose: A)dd new player P)rint all players L)ookup a player's score Q)uit L Enter name to look up. Michael Michael's score = 200 Score Management System Choose: A)dd new player P)rint all players L)ookup a player's score Q)uit Q
Submission Instructions Execute the program and copy/paste the output that is produced by your program into the bottom of the source code file, making it into a comment. I will run the programs myself to see the output. Make sure the run "matches" your source. If the run you submit could not have come from the source you submit, it will be graded as if you did not hand in a run. Use the Assignment Submission link to submit the source code file. Submit the following files: Player.java PlayersList.java ScoreManagementSystem.java
//Here is the prototype for ScoreManagementSystem.java import java.util.Scanner;
public class ScoreManagementSystem{ public static void main(String[] args) { Scanner input; PlayerManager highScores = new PlayerManager(); input = new Scanner(System.in); String choice = "";
// Main menu do { System.out.println(); System.out.println(); System.out.println("Score Management System"); System.out.println("Choose:"); System.out.println(); System.out.println("A)dd new player"); System.out.println("P)rint all players"); System.out.println("L)ookup a player's score"); System.out.println("Q)uit"); System.out.println(); choice = input.next(); input.nextLine(); // Discard newline if (choice.equalsIgnoreCase("A")) highScores.addPlayer(); else if (choice.equalsIgnoreCase("P")) highScores.printPlayers(); else if (choice.equalsIgnoreCase("L")) highScores.lookupPlayer(); System.out.println(); } while (!choice.equalsIgnoreCase("q")); } }
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