The class TimeBook in Listing 7.14 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 7.14 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 Chapter 6 in the section “Wrapper Classes.”
The solution to this project is based on TimeBook.java, Listing 7.14. A good approach to this problem is to add one feature at a time to NewTimeBook, then add the code to test the feature in NewTimeBookDemo.java. The default constructor was written to have just one employee. The features were added in the order that the tests appear in NewTimeBookDemo.java, with the method to align the numbers in the table done last.
See the code in NewTimeBook.java and NewTimeBookDemo.java.
You might also like to view...
Files on magnetic tape are usually accessed using:
a. A random access algorithm b. A sequential access algorithm c. A circular access algorithm d. A binary algorithm e. None of the above.
The Assets panel displays a graphic's filename, type, size, and location.
Answer the following statement true (T) or false (F)
?In an entity-relationship diagram, entities are commonly represented as _____.
A. ?triangles B. ?circles C. ?rectangles D. ?hexagons
There must be 24 GPS satellites in orbit at any given time in order to have at least ____ satellites in view from anywhere on the planet.
A. three B. four C. ?five D. six