Week 7 Homework

Instruction

Use the link provided by your professor to access the GitHub repo with the starter code.

This assignment consists of two parts.

Part 1: Complete Exercise 7.3

This exercise has you trace a program with multiple objects. The program with explanations can be found in Figures 7.2 and 7.3. The code can also be found in the assignment repository. Use this Excel file in the repository to use for the tracing.

Part 2: Complete the following program

In the GitHub starter code, skeletons for the Time and TimeDriver class have been provided. 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.