Question: a) Update the Player class so that rather than holding a field of type PairOfDice, it instead holds a field of type Rollable. You will

a) Update the Player class so that rather than holding a field of type PairOfDice, it instead holds a field of type Rollable. You will then need to update the three-argument custom constructor so it accepts any Rollable type, however the other constructors can assign a default object of your choice to this variable, so long that it is rollable.

b) The getPairOfDice method should be updated to getRollable, with a return type of Rollable.

c) You should run the unit tests in PlayerTest and check the progress you have made for this question and the general design of the class you started in the previous exercise.

d) Add a further void method setFullPlayerName(...) that accepts a single String argument (e.g. "Joe Bloggs") and then uses this to set the first and family name individually by extracting the relevant information and then calling the respective setter methods of the Name class. The first and family name should be capitalised (e.g. to "Joe" and "Bloggs") regardless of the case of the string argument so both "JOE BLOGGS" and "joe bloggs" should generate the same result.

e) Add a further void method generateGamerTag(...) that accepts an int argument and then uses this to generate a gamertag. The method should firstly ensure the number provided is between 1 and 100 anything outside of this range should result in no change. If the number provided is legitimate, the gamertag should be updated to be the players full name in reverse order (in lowercase and with no whitespace) with the given number appended. For example, if the number 50 was provided and the players name was "Joe Bloggs", the gamertag should be set to "sggolbeoj50".

f) In the src > main package, you will notice a class called PlayerApp that has a method called execute, which accepts an ArrayList and an int value and returns a String. Currently, it simply returns an empty string. It should however do the following: Return a String that contains the name of each player (which meets the criteria noted below *) in the ArrayList participants in the format: "FIRSTNAME, surname", e.g. "JOE, bloggs", each followed by a new line. * only players whose gamertag contains their surname (regardless of case) as well as the int number passed as a parameter to the execute method. In the test > main package there is a further JUnit Test Case PlayerAppTest containing a unit test called testExecute, which assesses whether the execute method behaves correctly. Please note: Your solution to part f) will be marked by using a different input data set of players within the list to ensure your solution works dynamically based upon any given data set and is not hardcoded in any way.

a) Update the Player class so that rather than holding a field

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!