Assignment Instructions

Java programming with bluej | Computer Science homework help.

 

Task #1 The Dice Game

  1. Write a TwoDice class with instance variables face, a two-element array to hold values you can roll with a pair of dice.
    1. Default constructor places random values 1..6 on each face
    2. Constructor with parameters n, m for the initial face values. Validate the parameters to allow only 1..6.
    3. Accessors getFace1( ), getFace2( ) and getTotal( ) which returns an integer.
    4. Mutators setFace1( ), setFace2( ) to set each to only 1..6 
    5. Mutator roll( ) which randomize the numbers on face1 and face2 to 1..6
    6. toString( ) method to return a string like “3, 4” or “6, 5”
    7. equals( ) method to compare a pair of dice with another pair of dice. Return true if they have the same face values.
    8. printMe( ) method for DEBUG. This should simply print the value in toString( ).
  2. Write a client DiceClient1YOURNAME.
    1. Instantiate and initialize a pair of dice
    2. Instantiate score, a 20 element integer array of integers and initialize it to all 0.
    3. 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.
    4. Each roll is entered in the array until you win, lose, or the array is full.
    5. 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.

  1. Roll the two dice up to 20 times and save the total in the array.
  2. If the total is 7 or 11, you win. Put this in the array, report the results and exit the game.
  3. If the total is 2, 3, or 12, you lose. Put this in the array, report the results and exit the game.
  4. If the total is anything else, save the total as the “goal”. put it in the array, and you get to roll again.
  5. 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.javaPreview the document

ClassicSongs.javaPreview the document

Song.javaPreview the document

  1. 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. 
  2. Fill the array by creating a new song with the title and artist and storing it in the appropriate position in the array. 
  3. Print the contents of the array to the console. 
  4. 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 

Java programming with bluej | Computer Science homework help

Calculate Price


Price (USD)
$

This assignment has been solved!

Place your order for a custom solution to this or a similar paper.

Why Choose Us For Your Assignment?

Privacy

We value all our customers' privacy. For that reason, all information stays private and confidential and will never be shared with third parties.

Punctuality

With our service you will never miss a deadline. We use strict follow-ups with our writers to ensure that all papers are submitted on time.

Authenticity

We have no tolerance for plagiarism. All papers go through thorough checking to ensure that no assignments contain plagiarism.

Money Back

You feel unsatisfied with your results? No worries. We offer refunds to our customers if any paper is not written according to the instructions.

Clients Love Us

Client #121678
Client #121678
Read More
This is by far the best I have ever scored in a custom essay. I am surprised the writer handled this assignment so well despite the short notice. I will definitely use your service next time.
Client #21702
Client #21702
Read More
When I was recommended to you by my friends, I wasn't sure you could deliver excellent results for Masters research papers until I submitted my first order. I am all yours now.
Client #20730
Client #20730
Read More
Excellent Services! You are the only assignment helper I can rely on. I have worked with many before and your services are exceptional. I have recommended you to my friends and the results are similar.
Client #20387
Client #20387
Read More
I rarely write reviews online but your services are worth promoting. My paper was so urgent I was sure I was gonna miss the deadline but you turned things around. You are awesome!
Client #20189
Client #20189
Read More
I am a satisfied customer. I know I should have given a 5 star because you deserve it but I will give 4.6 because I almost missed a deadline because of a revision. Luckily it was minor and the writer acted promptly.
Client #20187
Client #20187
Read More
Great paper but there is still some room for improvement. I am impressed by your fast responses and how you tacked my concerns professionally. Thank you for being among the few genuine essay writing service providers.
Client #19783
Client #19783
Read More
I can't thank you enough for being a great part of my college life. I recommended you to two more of my friends. I am sure they will be making their orders soon. I love the fact that you offer free pages for referrals. I will be referring a few more and maybe I won't have to pay for my next two paper, LOL.
Previous
Next