Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Writing a Dice Game Usiing Blue J Exercise

Writing a Dice Game Usiing Blue J Exercise

Question Description

I’m working on a java project and need support to help me learn.

Task #1 The Dice Game

  1. Write a DiceYI class with one instance variable, value.
    1. Constructor with a parameter for the initial face value. Validate that it allows only 1..6.
    2. Accessors getValue( ) which returns an integer.
    3. Mutators setValue( ) to set value. Validate it only sets 1..6
    4. Mutator roll( ) which randomize the instance variable to 1..6
    5. toString( ) method to return a string like “3” or “6”
    6. printMe( ) method for DEBUG. This should simply print the value in toString( ).
  2. Write a class (NOT A SUBCLASS) DicePairYI with a 2 element array of type DiceYI.
    1. Default constructor: Use Random class methods to initialize each DiceYI
    2. Constructor with a parameter for the initial face values. Validate that it allows only 1..6.
    3. Accessor getValue( i ) which returns the value of the first or second DiceYI.
    4. Accessor getTotal( ) which returns the sum the array DiceYI face values.
    5. Mutators setValue( i ) to set value. Let DiceYI validate it only sets 1..6
    6. Mutator roll( ) which randomizes each DiceYI in the array
    7. toString( ) method to return a string like “3, 4” or “6, 5”
    8. equals( ) method to compare a pair of dice with another pair of dice. Return true if they have the same face values. For example if one DicePairYI object has 4,6 and the other has 6,4 they are equal.
    9. printMe( ) method for DEBUG. This should simply print the value in toString( ).
  3. Write a client DiceGame1YOURNAME.
    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

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Executive Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Executive Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Executive Papers is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Executive Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.