Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In JAVA PLEASE. In this class you will implement two main classes: Player and PlayerDatabase to store the details of a set of players. You

In JAVA PLEASE.

In this class you will implement two main classes: Player and PlayerDatabase to store the details of a set of players. You will also create another class called A PlayerDatabaseDemo which will contain the main method to test the two classes. THERE IS NO INHERITANCE INVOLVED HERE.

The Player Class: This class should simulate a player. The classs responsibilities are as follows:

To know the players name, score, and shirt number. ASSUME that the name of the player consists of only ONE WORD/String.

Instance variables: String Name, int Score, int Shirt

Required methods: one copy constructor, two constructors, accessors and mutators. The constructors are given below. The Default constructor is written for you. You need to complete the other two constructors.

public Player()

Name = ;

Score = 0;

Shirt = 0;

public Player(String newName, int newScore, int newShirt)

{

}

public Player(Player P)

{

}

The PlayerDatabase Class: The object of this class should store a list of up to 10 objects of the class Player. This class should have private Player[] players and private int numPlayers as instance variables. The class should have only one constructor (given below)

public PlayerDatabase(int num)

{

numPlayers = num;// need to update this

//when you add, //remove players.

players = new Player[numPlayers];

}

This class should support the following methods (See below). You can add additional methods if you need to. Keep in mind; the maximum number of players is 10. In the methods, you need to make sure that the database doesnt allow the user to add exceed more than 10 players. To make things easier lets assume no two players have the same name. In any of the search methods, if the player couldnt be found, you should display that the player wasnt found in the database.

Add a new player to the PlayerDatabase through a series of inputs (from keyboard) from the user.

public void AddPlayer()

// not more than 10 players in the database allowed

Add a set of players to the PlayerDatabase through a file.

public void AddPlayer(String PlayersFile, int num)

{

//num is the number of players in the file.

numPlayers = num;

// not more than 10 players in the database allowed

}

The File PlayersFile contains several lines, where each line is of the format

PlayerName score shirtnumber

Given a list of players, display players names, scores, and shirt number on the screen (one player per line). THIS method should always display the players in descending order of their scores.

public void DisplayPlayers(Player[] players)

{

}

Allow the user to enter a players name, this method finds the player with that specific name in the database and then displays that players name, score and shirt number. This method should give a not found message if the player wasnt found in the database.

public void SearchPlayersByName(String playerName)

{

}

Allow the user to enter a players shirt number, this method finds the player with that specific shirt number in the database and then displays that players name, score and shirt number. This method should give a not found message if the player wasnt found in the database.

public void SearchPlayersByshirt(int playerShirtNumber)

{

}

Allow the user to enter a players score, this method finds ALL THE players with that specific score in the database and then returns all the matching players. This method should give a message if no players were found.

public Player[] SearchPlayersByScore(int playerScore)

{

}

Allows the user to enter a players name and remove the player having that name from the database. This method should give a message if no players were found.

public void RemovePlayerByName()

{

}

Prints the players name, score, and shirt number contained in PlayerDatabase

public void DisplayPlayers()

{

}

A PlayerDatabaseDemo Class to test the above two classes. This class will only have the main method. In the main method you will test the two classes Player and PlayerDatabase

public class PlayerDatabaseDemo

{

public static void main(String[] args)

{

//Testing the copy constructor of Player

// Player p1 = new Player(Sam,20,1);

// Player p2 = new Player(p1);

// p1.setName(John);//setName() is a mutator method

// System.out.println(p1.getName() == p2.getName()); //should be false //getName() is an accessor method

// PlayerDatabase Sim= new PlayerDatabase();

/*

Use AddPlayer(String PlayersFile) to load players

Display number of players in the database

3. You should display all the players in the database- their names,

scores and shirt numbers (one player per line)

4. Here you need to create a menu system that allows the user to select

which option or method to invoke from the Class PlayerDatabase. Provide an option to

allow the user to exit from the menu

5. After it exits from the menu system, display number of remaining

players in the database. Then, display all the remaining players -their

names, scores and shirt numbers in the database (one player per line)

*/

}

}

A Sample players File:

John 20 1

Walter 402

David 45 10

Sam 0 20

Little 0 22

General Instructions:

Please use Eclipse or other Java IDE environment to make sure that your program is running before your final submission.

Make sure it is giving the right output by running your program in Eclipse or other IDE environment.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

1. Signs and symbols of the map Briefly by box ?

Answered: 1 week ago

Question

Types of physical Maps?

Answered: 1 week ago

Question

Explain Intermediate term financing in detail.

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago