Clock - /class Clock public class Clock cfw_ private int...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//class Clock / public class Clock { private int hr; //store hours private int min; //store minutes private int sec; //store seconds //Default constructor //Postcondition: hr = 0; min = 0; sec = 0 public Clock() { setTime(0, 0, 0); } //Constructor with parameters, to set the time //The time is set according to the parameters //Postcondition: hr = hours; min = minutes; sec = seconds public Clock(int hours, int minutes, int seconds) { setTime(hours, minutes, seconds); } //Method to set the time //The time is set according to the parameters //Postcondition: hr = hours; min = minutes; sec = seconds public void setTime(int hours, int minutes, int seconds) { hr = hours; else hr = 0; min = minutes; else min = 0; sec = seconds; else sec = 0; } //Method to return the hours //Postcondition: The value of hr is returned. public int getHours()
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Clock - /class Clock public class Clock cfw_ private int...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online