Question: 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,
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.”)
Listing 7.14
![Class that records the t ime worked by each of a company's employees during one five-day week. A sample application is in the main method. */ public class TimeBook { private int numberofEmployees; //hours[i][j] has the hours for //employee j on day i. private int[]) hours; private int[0 weekHours; //weekHours[i]](https://dsd5zvtm8ll6.cloudfront.net/si.question.images/images/question_images/1606/3/7/0/9565fbf468c545301606370955371.jpg)


![method. */ public class TimeBook { private int numberofEmployees; //hours[i][j] has the](https://dsd5zvtm8ll6.cloudfront.net/si.question.images/images/question_images/1606/3/7/0/9985fbf46b60f08c1606370997637.jpg)
Class that records the t ime worked by each of a company's employees during one five-day week. A sample application is in the main method. */ public class TimeBook { private int numberofEmployees; //hours[i][j] has the hours for //employee j on day i. private int[]) hours; private int[0 weekHours; //weekHours[i] has the week's //hours worked for employee i + 1. private int 0 dayHours; //dayHours[i] has the total hours //worked by all employees on day i. private static final int NUMBER_OF_WORKDAYS = 5; private static final int MON = 0; private static final int TUE = 1; private static final int WED = 2; private static final int THU = 3; %3D private static final int FRI 43B
Step by Step Solution
3.24 Rating (176 Votes )
There are 3 Steps involved in it
public class NewTimeBook Default constructor if number of employess is not specified defaults to one employee public NewTimeBook numberOfEmployees 1 hours new int5numberOfEmployees the 5 is for the 5 ... View full answer
Get step-by-step solutions from verified subject matter experts
