CSC1110 Homework 7

Complete Exercise 7.3 (pp. 317)

This exercise has you trace a program with multiple objects. The program with explanations can be found on pages 277-278 (Figures 7.2 and 7.3). The code can also be found in the assignment repository. There is an Excel file in the repository to use for the tracing.

Complete the following program

Using the following Time and TimeDriver class skeletons, replace the < insert ...> lines with your own code such that the program operates properly. More specifically:

public class Time  {  
    private int hours;  
    private int minutes;  
    private int seconds;  


    <insert setHours method definition here>  

    public Time setMinutes(int minutes)  {  
        this.minutes = minutes;
        return this;  
    } // end setMinutes  

    public Time setSeconds(int seconds)  {  
        this.seconds = seconds;
        return this;  
    } // end setSeconds  


    public void printTime()  {  
    System.out.printf("%02d:%02d:%02d\n", hours, minutes, seconds);  
    } // end printTime  
} // end Time class  

public class TimeDriver  {  
    public static void main(String[] args)  {  
       Time time = new Time();  
        <insert chained-method-calls statement here >  
} // end TimeDriver class 

Submission Instructions:

Commit and Push your files to GitHub Classroom.