jplay
Class Time

java.lang.Object
  extended by jplay.Time

public class Time
extends java.lang.Object

Class used to manipulate time.


Constructor Summary
Time(int x, int y, boolean crescentTime)
          Creates an instance of the class Time.
Time(int hour, int minute, int second, int x, int y, boolean crescentTime)
          Creates an instance of the class Time.
Time(int hour, int minute, int second, int x, int y, java.awt.Font font, java.awt.Color color, boolean crescentTime)
          Creates an instance of the class Time.
 
Method Summary
 void draw()
          Draws the time on the screen.
 void draw(java.lang.String message)
          Draws a message before the time on the screen.
 int getHour()
          Returns the hours.
 int getMinute()
          Returns the minutes.
 int getSecond()
          Returns the seconds.
 long getTotalSecond()
          Returns the time in seconds.
 void setColor(java.awt.Color color)
          Sets the color used to drawn the time on the screen.
 void setFont(java.awt.Font font)
          Sets the font used to drawn the time on the screen.
 void setHour(int hour)
          Sets the hours.
 void setMinute(int minute)
          Sets the minutes.
 void setSecond(int second)
          Sets the seconds.
 void setTime(int hour, int minute, int seconds)
          Sets the current time.
 boolean timeEnded()
          Returns true when the time comes to zero, false otherwise.
 java.lang.String toString()
          Returns a string with the time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Time

public Time(int x,
            int y,
            boolean crescentTime)
Creates an instance of the class Time. The time will have house = 0, minute = 0, seconds = 0. It will be drawn on the screen with the font = Arial, size= 20 and the color = yellow.

Parameters:
x - value of the coordinate X.
y - value of the coordinate Y.
crescentTime - true if the is crescent, false otherwise.

Time

public Time(int hour,
            int minute,
            int second,
            int x,
            int y,
            boolean crescentTime)
Creates an instance of the class Time.

Parameters:
hour -
minute -
second -
x -
y -
crescentTime - true if the is crescent, false otherwise.

Time

public Time(int hour,
            int minute,
            int second,
            int x,
            int y,
            java.awt.Font font,
            java.awt.Color color,
            boolean crescentTime)
Creates an instance of the class Time.

Parameters:
hour -
minute -
second -
x -
y -
font -
color -
crescentTime - True if the time is crescent, false otherwise.
Method Detail

toString

public java.lang.String toString()
Returns a string with the time. The time format is hour/min/second (00/00/00).

Overrides:
toString in class java.lang.Object
Returns:
String

draw

public void draw(java.lang.String message)
Draws a message before the time on the screen.

Parameters:
message -

draw

public void draw()
Draws the time on the screen.


setColor

public void setColor(java.awt.Color color)
Sets the color used to drawn the time on the screen.

Parameters:
color -

setFont

public void setFont(java.awt.Font font)
Sets the font used to drawn the time on the screen.

Parameters:
color -

timeEnded

public boolean timeEnded()
Returns true when the time comes to zero, false otherwise. It's only work if the time is crescent.

Parameters:
boolean -

setHour

public void setHour(int hour)
Sets the hours.

Parameters:
hour -

setMinute

public void setMinute(int minute)
Sets the minutes.

Parameters:
minute -

setSecond

public void setSecond(int second)
Sets the seconds.

Parameters:
second -

getHour

public int getHour()
Returns the hours.

Returns:
int

getMinute

public int getMinute()
Returns the minutes.

Returns:
int

getSecond

public int getSecond()
Returns the seconds.

Returns:
int

getTotalSecond

public long getTotalSecond()
Returns the time in seconds. Example: 1h 29 min e 45 seconds will be returned as 1*60*60 + 29*60 + 45 = 217785 seconds.

Returns:
long

setTime

public void setTime(int hour,
                    int minute,
                    int seconds)
Sets the current time.

Parameters:
hour -
minute -
seconds -