Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA required In the test > lib package you have been given a JUnit Test Case PlayerTest containing unit tests, which will be used to

image text in transcribed

JAVA required

In the test > lib package you have been given a JUnit Test Case PlayerTest containing unit tests, which will be used to mark your implementation of the Player class. You can use it to gain progressive feedback on your design, however, some tests will not pass at this stage and are designed to test functionality that you will add later in this exercise. It is important that you use the same method signatures and return types as those specified in the test program, e.g. note the method called setFullPlayerName invoked in the testSetFullPlayerName unit test meaning this exact name needs to be used for the corresponding method in your Player class.

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. g) As this is a portfolio question, you should update the Javadoc you have previously written for the Player class where necessary to ensure it accurately reflects the updated class

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_2

Step: 3

blur-text-image_3

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

Data Analysis In Microsoft Excel

Authors: Alex Holloway

1st Edition

B0CCCPKTTX, 979-8852388452

More Books

Students also viewed these Databases questions

Question

Prepare for a successful job interview.

Answered: 1 week ago

Question

Describe barriers to effective listening.

Answered: 1 week ago

Question

List the guidelines for effective listening.

Answered: 1 week ago