FileDocCategorySizeDatePackage
Time.javaAPI DocExample954Wed Jan 09 13:40:40 GMT 2002None

Time

public class Time extends Object

Fields Summary
private int
h
private int
m
private int
s
Constructors Summary
Methods Summary
public voiddisplayH()

	System.out.println("The hour is " + h);
// The method body
public voiddisplayM()

	System.out.println("The minute is " + m); 	
// The method body
public voiddisplayS()

	System.out.println("The second is " + s); 	
// The method body
public voidsetTime(int hour, int min, int sec)

if ((hour>=0)&&(hour<24)&&(min>=0)&&(min < 60)&&(sec>=0)&&(sec<60))
		{ 
		h=hour;
		m=min;
		s=sec;
		}
	else 
		System.out.println("Illegal time");
public voidtick()

	s++;
	if (s==60)
	{
		s=0;
		m++;
	}
	if (m==60)
	{
m=0;
		h++;
	}
	if (h==24)
		h=0;