Skip to main content

Ode to Joy by Bach The Sleeping Beauty by Tchaikovsky

 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 


Comments

Popular posts from this blog

Starting with this provided code, add the following functionality

1.Starting with this provided code, add the following functionality: Replace hardcoded strings “Zero”, “One”, “Two”, “Three” in the ArrayList based on user typed input (use Scanner or JOptionPane classes). The user will be prompted for the String to be stored in the ArrayList and then hit enter. The user will be able to continue to add items to the ArrayList until they just hit enter without typing anything. Once the user does this (hits enter without typing anything), the program will display all of the elements of the ArrayList, both the index and String values, in a table. It will do this via a single loop making use of an iterator method. 2. Starting with this provided code, add the following functionality: Use a Try/Catch block so that the exception is caught and the program exits a bit more gracefully. Save this file as TryCatch.java. (Be sure to rename the Public Class accordingly.) Starting with the provided code again (without the Try/Catch block), fix the code so that

Josie Eskander

  Question 1: Task 1: Report Assume you are Josie Eskander. You are writing in response to techno trading P/L’s advertisement of a new laptop at 20% below normal price. You want information on brand name, availability of service and repairs, delivery times and methods of payment. Write the letter using the seven basic parts of the letter. In the opening paragraph present a clear and courteous request. Secondly write a response from techno trading giving details and proposing the sale. Provide draft of both emails in the space below. Question 2: Task 2: Report In pairs, nominate a good and a bad letter writer. Discuss the key differences. Write a good/bad letter from techno training to Alex Antonov accepting/declining his proposal to invest in the business Question 3: Task 3: Report Write a letter from techno trading p/l to a new client ‘new realities p/l’ urging them to buy techno new virtual reality software. Make a strong argument for the product. Question 4: Task 4: Report Write a l

THE AMERICAN REVOLUTION AND THE EARLY REPUBLIC

Assignment Overview The American Revolution and Independence As we saw in the Module Overview, there were numerous factors that ultimately led to revolution and independence. In this second Case assignment, you’ll be researching and writing about some of those factors. Case Assignment Write a 3 to 4-page essay identifying at least FOUR factors which led to colonial independence. In your paper, explain which events triggered discord between the colonies and the Mother Country. Be sure to do some research on your own and use other resources to analyze the thought-processes which sparked independent thinking. The best way to approach and organize the paper would be to create a title for each event and then discuss your findings. For example; for the first one you could write, “Event 1, The Seven Years War”. This would be followed by your narrative on how this war led to independence. The rest of the paper would follow this pattern. Assignment Expectations Use concepts from the background