Problem

The class TimeBook in Listing is not really finished. Complete the definition of this clas...

The class TimeBook in Listing is not really finished. Complete the definition of this class in the way described in the text. In particular, be sure to add a default constructor, as well as set and get methods that change or retrieve each of the instance variables and each indexed variable of each array instance variable. Be sure you replace the stub setHours with a method that obtains values from the keyboard. You should also define a private method having two int parameters that displays the first parameter in the number of spaces given by a second parameter. The extra spaces not filled by the first parameter are to be filled with blanks. This will let you write each array element in exactly four spaces, for example, and so will allow you to display a neat rectangular arrangement of array elements. Be sure that the main method in Listing works correctly with these new methods. Also, write a separate test program to test all the new methods. (Hint: To display an int value n in a fixed number of spaces, use Integer. toString(n) to convert the number to a string value, and then work with the string value. This method is discussed in the section “Wrapper C lasses.”)

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT