You will be creating 2 Java files for this assignment: and
You will be creating 1 Word document that contains the UML diagram of the Die class

Part 1 – The Die Class

            The program

Design a Die class that contains the following attributes:

  • sides: represents how many sides a dice has. A dice usually has 6 sides but sometimes could have more. This will be provided by the user
  • value: represents the current value that was rolled in the dice.

The die Class should have the following methods:

  • Constructor: takes one parameter that represents the number of sides in the dice. It then rolls the dice to give it an initial value
  • Accessor methods: Should return the fields of the Die class.
  • roll: Randomly generates a value within the number of sides of the dice. For example, if the dice has 6 sides you need to set value to be a random number between 1 and 6. If the dice has 12 sides, you need to set the value to a random number between 1 and 12 and so on… (Hint, this function is of type VOID)

            The UML diagram

Before you start programming, take a moment to figure out all the fields that you will need and all the methods that need to be created. Create the UML diagram for the Coin class. Don’t forget to account for the access specifiers (public or private), for the data types of the fields and for the return types and the parameters of the methods.

            Commenting and Programming Style

The first 3 lines of you program should have a multiline comment (Starting with /*  and ending with */). This should include the author’s name, the date and the purpose of the assignment.
You should create a documentation comment before every class header and method header (Starting with /** and ending with */). For now, the comment only needs to describe the purpose of the method. We will improve our comments throughout the semester. A sample is provided below.
Don’t forget to add spaces before and after every operator and to align braces.

Part 2 – The TestDie Class

            The Program

The program should create two instances of the Die class (each a six-sided die). One Die object is the computer’s die, the other Die object is the user’s die.
The program should have a loop that iterates 20 times. Each time the loop iterates, it should roll both dice. The die with the highest value wins. (In case of a tie, there is no winner for that particular roll of the dice).
As the loop iterates, the program should keep count of the number of times the computer wins, and the number of times that the user wins. After the loop performs all of its iterations, the program should display who was the grand winner, the computer or the user.
Finally, if the user wins, the program must ask the user to enter a nickname (The nickname must be at least 1 character and at most 5 characters), keep asking to user to enter a name while it is not valid. Once the user enters their nickname, append their nickname and number of wins to a file called “scores.txt”. Opening this file will contain the score of every player that has won the game.

            Commenting and Style

In this test file, the first 3 lines of you program should have a multiline comment (Starting with /*  and ending with */). This should include the author’s name, the date and the purpose of the file.
Add a documentation comment (/**      */) explaining what methods you will be testing on the program.
You should then include single line comments throughout your main method to explain what you are doing. For example:
Don’t forget to add a space before and after operators and to align braces.

Submission and Grading:

Submit, and the UML diagram through Blackboard. You can compress the files if you want.
Your grade will be determined based on the following rubric:

Task Points
Die UML diagram 10 points contains all required attributes w/ correct data types and access specifiers 5 points
Die  class contains a constructor method 10 points
Die class contains all accessor and mutator methods 10 points
Die class contains a method to roll the dice 10 points
TestDie tests uses the constructor to set up a new object 10 points
TestDie correctly uses a  loop to roll multiple dice 10 points
TestDie correctly decides who won the match 10 points
TestDie correctly saves nicknames and number of wins to “score.txt” 10 points
Documentation & Style 15 points
Total 100 points


If the program does not compile or run, 30 points will be deducted from your total.
It is very important to test your program!

"Do you want an original answer to this question?

Yes No

"Is this question part of your assignment? Essay
.We Can Help!

Order Now