Need help? We are here

Task #1 The Dice Game
Write a TwoDice class with instance variables face, a two-element array to hold values you can roll with a pair of dice.
Default constructor places random values 1..6 on each face
Constructor with parameters n, m for the initial face values. Validate the parameters to allow only 1..6.
Accessors getFace1( ), getFace2( ) and getTotal( ) which returns an integer.
Mutators setFace1( ), setFace2( ) to set each to only 1..6
Mutator roll( ) which randomize the numbers on face1 and face2 to 1..6
toString( ) method to return a string like 3, 4 or 6, 5
equals( ) method to compare a pair of dice with another pair of dice. Return true if they have the same face values.
printMe( ) method for DEBUG. This should simply print the value in toString( ).
Write a client DiceClient1YOURNAME.
Instantiate and initialize a pair of dice
Instantiate score, a 20 element integer array of integers and initialize it to all 0.
Write a play( ) method for a new game, it should reset the game and then continuously roll the dice until you win or lose or the array is full.
Each roll is entered in the array until you win, lose, or the array is full.
Write a printArray( ) method to print the score array on ONE line. Make it easy to read by adding a – after every 5 scores e.g.


4
8
9
8
5


7
0
0
0
0


0
0
0
0
0


0
0
0 0
0
The rules of the game: A player rolls the two dice and adds the number shown on them.
Roll the two dice up to 20 times and save the total in the array.
If the total is 7 or 11, you win. Put this in the array, report the results and exit the game.
If the total is 2, 3, or 12, you lose. Put this in the array, report the results and exit the game.
If the total is anything else, save the total as the goal. put it in the array, and you get to roll again.
The new objective is to roll the same total as the goal.
You keep rolling until you either get goal or a 7. Show the array.
If you roll goal, you win. Put this in the array, report the results and exit the game.
If you roll a 7, you lose. Put this in the array, report the results and exit the game.
Sample Terminal:
You win:
10 10 0 0 0 – 0 0 0 0 0 – 0 0 0 0 0 – 0 0 0 0 0
You win:
7 0 0 0 0 – 0 0 0 0 0 – 0 0 0 0 0 – 0 0 0 0 0
You win:
8 11 8 0 0 – 0 0 0 0 0 – 0 0 0 0 0 – 0 0 0 0 0
You lose:
6 3 3 7 0 – 0 0 0 0 0 – 0 0 0 0 0 – 0 0 0 0 0
You lose:
4 5 5 12 9 – 6 6 7 0 0 – 0 0 0 0 0 – 0 0 0 0 0
You win:
8 8 0 0 0 – 0 0 0 0 0 – 0 0 0 0 0 – 0 0 0 0 0
Task #2 Arrays of Objects Copy the files Song.java, CompactDiscYOURNAME.java and ClassicSongs.java as directed by your instructor. Song.java will be completed in class. ClassicSongs.java is the data file that will be used by CompactDiscYOURNAME.java, the file you will be editing.
CompactDiscYOURNAME.java
ClassicSongs.java
Song.java
In CompactDisc.java, there are comments indicating where the missing code is to be placed. Declare an array of Songs, called cd, with a size of 6.
Fill the array by creating a new song with the title and artist and storing it in the appropriate position in the array.
Print the contents of the array to the console.
Compile, debug, and run. Your terminal output should be:
Contents of Classics:
Ode to Joy by Bach
The Sleeping Beauty by Tchaikovsky
Lullaby by Brahms Canon by Bach
Symphony No. 5 by Beethoven
The Blue Danube Waltz by Strauss

Connect with a professional writer in 5 simple steps

Please provide as many details about your writing struggle as possible

Academic level of your paper

Type of Paper

When is it due?

How many pages is this assigment?