In this exercise you will write a simple program to maintain a list of players of an online game. Your program must read in details of players of an online game and both retrieve and manipulate these details.
Players of an online game are identied by their surname (you may assume this is a single string, in which the rst letter is a capital. E.g. Miller, or Smith), gender (M/F) and high score (an integer between 1 and 100).
(l) Create a text le containing a list of (randomly ordered) players, this le should be called players.txt and contain at least 20 entries in the form: surname (gender) high-score, and each player should be on a separate line, like in the following example:
Miller (F) 17
Smith (M) 5
Jones (F) 27
(etc.)
(2) Create a class Player to represent a player. Each Player object should consist of 3 elds of type String, Boolean and int representing the surname, gender and high-score of the Player. Your class should contain:
(3) Create a class Players.java to represent a list of players. Each Players object should consist of a list of players and the current size of the list. Your class should contain;
Note that the constructor should create a list using an appropriate List. constructor from an implementing class (e.g. an ArrayList, as per the example given in Lecture 1).
(4) Create a class OrqanisePlayers.java which contains a main method and can be used to organize and manipulate the players. All of the functions of this class must use the methods of the Player .java and Players.java classes (i.e. this class should not include any methods itself). You may therefore need to add suitable methods to your other classes to achieve the requirements of this class. Complete this class to:
(Hint: Note that in the arrays section of the lectures we sorted an array using Javas Array class sort method. To sort a List we use a sort method from Javas Collections method.)
When you are sure your program is working correctly, edit your program so that all output is sent to a text le called output.txt. You will be submitting this text le as a demonstration of your pr0grams effectiveness, so make sure that it contains enough evidence that your classes and methods work correctly. For example, an output le for an original list of 3 players:
Miller (F) 17
Smith (M) 5
Jones (F) 27
Adams (M) 10
Would contain (at last) the following information:
The list of players is:
Miller (F) 17
Smith (M) 5
Jones (F) 27
Adams (M) 19
The high score is: 27
The (name)-sorted list is:
Adams (M) 10
Jones (F) 27
Miller (F) 17
Smith (M) 5
The (high-score)-sorted list is:
Jones (F) 27
Miller (F) 17
Adams (M) 10
Smith (M) 5
This problem should be solved using the List; class, which was introduced in 1 of the course notes. You can nd full documentation of the collection classes at docs.oracle.com/javase/7/does/api.