Expert answer:Java assignments

Solved by verified expert:Java assignments.
java7.0.docx

Unformatted Attachment Preview

Surname 1
Part1
Watch this video/tutorial about Java inheritance AND Polymorphism (BOTH SECTIONS): http://horton.com/consulting/portfolio/OOPs/index.html
(Links to an external site.)
Links to an external site.
, then type a summary of the videos/tutorials (in your own words)
HERE.
Part2
Read Lesson 7, pages 7.1 through 7.5, then complete the following:
Write the UML diagram first, then write the class in Java for the
Commissioned class (details below).
The superclass given here is called Employee. The UML class diagram and class are shown in a link in Lesson 7, from page 7.5.
One subclass of Employee (called Salaried) is also shown in the
link given in Lesson 7, from page 7.5.
Write another subclass of Employee called Commissioned. The
Commissioned class has a private instance variable for commission rate. Include a constructor, accessor method, mutator
method (for the commision rate) and toString method. See the
Salaried class as an example.
Part3
Read Lesson 7, to page 7.7, then complete the following:
Using the example code for the abstract Employee class (in the
Lesson 7 link called Abstract Class Example), write a subclass of
the abstract Employee class called Commissioned, which includes private instance variables for amount sold and commission
rate, and a constructor that includes parameters to initialize those
as well as the superclass variables. Don’t forget to override the
computePay method (just multiply the amount sold times the commission rate). Write a driver program that will contain an array
Employee objects, initialized to instances of Commissioned and
Surname 2
Salaried shown in the Exercise 7.2 Canvas link. Then write a loop
to print the toString AND return value of computePay on each
Employee array element (you DON’T need to check if Salaried or
Commissioned!)
Employee [] empArray= new Employee[] {
new Commissioned(“Donald Duck”, “123-45-6789”, 5000.0, 0.22),
new Salaried(“Mickey Mouse”, “987-65-4321”, 100000.),
new Salaried(“Bugs Bunny”, “121-21-2121”, 90000.),
new Commissioned(“Elmer Fudd”, “343-43-4343”, 3000., 0.25) };
UPLOAD ONLY THE Commissioned.java file and the driver file.
Part4
Exercise 7.3 (due date and time shown below,, no late submissions allowed, upload the .java files) (Read Lesson 7, page
7.8, and see Example for Exercise7-3.pdf which will help you with
this exercise, then complete the following.)
Write an interface called Comparable that has an instance
method that returns an int called compareTo with 1 Object parameter. (Note that there is a library interface for this, but don’t use
the library version, write it as an exercise.) Modify the Employee
class from Lab Exercise 7.1 to implement this interface. Override
the compareTo (be sure to cast the parameter appropriately) to
first compare the names (use compareToIgnoreCase), but if
they’re the same, compare the SSNs using compareTo (don’t
compare Strings using ==). The return value should be either the
result of compareToIgnoreCase for the names (if not 0) or compareTo for the SSNs (if the names are the same).
Part5
Read Lesson 7, to page 7.9, then complete the following:
Add to the Node class in the Chapter 7 Canvas lesson page 7.6
to include an accessor that returns the data (Object), an accessor
Surname 3
that returns the next, a mutator for the data and a mutator for the
next.
Write a static method that reads a Double from the user (prompt
first), then instantiates a new Node passing the Double (and null
for next). Return that Node.
Write main to call the method, then call the accessor on the returned Node to get the data. Calculate the square of the data of
the returned Node, then instantiate a new Node passing the
squared data and the node returned from the static method (as its
next) (save this new Node, I’m calling newNode). Display the return value of the accessor for the data of newNode. Get the next
node of newNode using its accessor for the getting the next and
display the return value of the accessor for its data. RUN THIS
program. Turn in the class and output (copied and pasted at the
end of the .java file, commented out).
Part 6
Upload to Canvas the UML class diagrams for the WordDatabase
and Hangman classes, source (.java) files and output (copied
and pasted to the end of the main file, commented out), ALL
ZIPPED INTO ONE ZIP FILE
Problem: Write a program in Java to play a game of Hangman
(non-graphic). This is for practicing using the String, StringBuilder
classes and arrays of Strings. You need the following classes in
your program:
Write a Java class (call it WordDatabase) which contains (note
that each method below is an instance method– NOT static):
• private instance array of Strings, assigned to the strings
given in “HW4-WordList” on Canvas
• private instance variable for the current index (int)
• a default constructor (which calls the method to shuffle the
String array)
• accessor for the array size
Surname 4

method that returns the “current” string (string at the current
index), if the current index < array size, or null if current index == array size. This method will increment the current index before returning. • a public method that has NO PARAMETERS, that shuffles the array of Strings in the following manner: in a for loop (for index =0; index< array.length;++index) get a random index between 0 and array.length-1 (inclusive), swap the array element at index with the array element at the random index. This method also sets the current index (instance variable) to 0. • a public method that returns true if there are more elements in the array (current index < array size), otherwise it returns false Write a Java class (call it Hangman) which contains (note that each method below is an instance method-- NOT static): • private instance WordDatabase object variable • private instance String (for the current "answer") • private (instance) StringBuilder for the player's string of correct answers (see below of what that should look like) • private instance StringBuilder for the player's char guesses (in the order guessed, whether correct or not), which is used to determine if it was guessed already • a default constructor (assign to the WordDatabase instance variable a new WordDatabase, and new default StringBuilders to the StringBuilder instance variables here or in their declarations) • a PRIVATE instance method for initializing for a new game (gets the next String from the WordDatabase*, clears the StringBuilder** with the char guesses, and sets the StringBuilder** for the player's correct answers to all underscores ('_') (only for the number of chars in the current answer). Return true. *if the WordDatabase runs out of words, return false Surname 5 **NEVER ASSIGN A new StringBuilder instance (except in the constructor or its declaration), BUT JUST CHANGE THE CHARS IN IT (OR POINTS OFF)! • a public instance method for playing hangman: the player has up to 6 incorrect guesses to guess all the letters in a word before he/she "dies" (so remember to initialize a bad guess counter to 0, as well as the other). First call the private instance method for initializing a new game. Then, in each loop iteration, do all of the following (1, 2, 3, then 4 OR 5): 1 display the player's correct answers (StringBuilder) with a space between so the user could see the separation between underscores OR POINTS OFF) AND the bad guess counter (could count down if you want). 2 ask the user for a letter and read the user's guess into a String 3 convert their input to lowercase 4 if the 1st char isn't a letter, OR the user guessed it already, display an error message, otherwise... 5 display the results as shown in the test runs, including how many guesses MAKE SURE YOU USE THE INSTANCE VARIABLES IN THE GAME! (Note: you should write private methods called from this method so this method doesn't get too long!) (Optional: write another class for a Player that contains the StringBuilders mentioned in the Hangman class, so the Hangman class would have an instance variable for a Player instead of the 2 StringBuilders. You would need to have accessors and mutators for the StringBuilders.) Write a Java driver class in which main is in a separate class and file from the WordDatabase and Hangman classes (I'm calling it Prog4). In main, declare a Hangman object variable, instantiate it (ONLY ONCE FOR THE WHOLE PROGRAM), then in a loop, allow the user to play several games of Hangman. Stop the loop when the user doesn't want to play, or until the Hangman game Surname 6 won't initialize. It's up to you how to determine if the user doesn't want to play again. Note: Do not declare any class-scope variables in the main (Prog4) class except the Scanner object for System.in. Use the Scanner class a nextLine() or next() method. EACH String and StringBuilder method MUST use the length method, NOT A HARD-CODED NUMBER nor a variable for the size ! YOU'RE NOT ALLOWED TO USE ANY CHAR ARRAY NOR CONVERT ANY String NOR StringBuilder TO A CHAR ARRAY! DO NOT traverse a String or StringBuilder (except to display with spaces between chars). Instead use String and StringBuilder methods for searching for and replacing chars!!! Make sure you never go outside the bounds of an array, String or StringBuilder. Turn in with the user losing (running out of guesses), the user guessing the answer, and the user repeating guessed letters and non-letters. See the test runs on Canvas. Fill the array of Strings in the WordDatabase with these words file on Canvas ("HW4-WordList"). ALSO, TEST running out of words by putting only 2 words in the array. SEE Extra credit #4 in CodeLab. ... Purchase answer to see full attachment

How it works

  1. Paste your instructions in the instructions box. You can also attach an instructions file
  2. Select the writer category, deadline, education level and review the instructions 
  3. Make a payment for the order to be assignment to a writer
  4.  Download the paper after the writer uploads it 

Will the writer plagiarize my essay?

You will get a plagiarism-free paper and you can get an originality report upon request.

Is this service safe?

All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 20% with the discount code ESSAYHELP