Time - hours = h-1 12 instance methods private void...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class Time { // instance data = values for each different time object private int hours; private int minutes; private boolean morning; // constructors public Time(int h, int m, char ap) { hours = h; minutes = m; setWhen(ap); } public Time(int t) { int h = t / 100; int m = t % 100; if (h == 0) { hours = 12) morning - true;; } else if (h > 12)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { hours = h -1 12; } // instance methods private void setWhen(char ap) { ap = Character.toLowerCase(ap); if ap == 'a' morning = true; // check for invalid data else morning = false; } public void display() { System.out.printf("%d:%.2d ", hours, minutes); System.out.println(" }...
View Full Document

This note was uploaded on 04/03/2010 for the course COMPSCI 600.107 taught by Professor Houlahan during the Spring '08 term at Johns Hopkins.

Ask a homework question - tutors are online