Class MyTimerTask

java.lang.Object
  extended by java.util.TimerTask
      extended by MyTimerTask
All Implemented Interfaces:
Constants, java.lang.Runnable

 class MyTimerTask
extends java.util.TimerTask
implements Constants

MyTimerTask is a sub class of the TimerTask class. This class defines tasks that are performed when a Timer object starts operations according to a specified schedule.

Version:
1.0.0
Author:
Michiru Nishikawa

Field Summary
private  PlusNumber owner
          PlusNumber object that creates and has this TimerTask object.
private  java.lang.String sessionState
          String representing the current session state.
 
Fields inherited from interface Constants
BIG_FONT, CREAM1, CREAM2, CYAN, IMG_FILE_NAMES_MAIN, IMG_FILE_NAMES_NUMBER, IMG_FILE_NAMES_SPLASH, INST_HEADINGS, INST_IMG_FILE_NAMES, MAX_TIME, MEDIUM_FONT, MENU_ITEM_NAMES, MENU_NAMES, NOT_SELECTED, ORANGE, PLAYED, RED, SELECTED, SMALL_FONT, SMALLER_FONT, SMALLEST_FONT, SOUND_FILE_NAMES, YELLOW
 
Constructor Summary
MyTimerTask()
          Default constructor that initialise attributes by caling a non-default constructor.
MyTimerTask(PlusNumber owner)
          Constructor initialising all attributes with receiving one argument.
MyTimerTask(PlusNumber owner, java.lang.String sessionState)
          Constructor initialising all attributes with receiving two arguments.
 
Method Summary
private  void processCorrectAfterOneSecond()
          This method is called by a GamePanelActionLister object when a game panel is clicked and the total sum becomes equals to a question number.
private  void processExceedAfterOneSecond()
          This method is called by a GamePanelActionLister object when a game panel is clicked and the total sum exceeds a question number.
private  void processTimer()
          This method defines tasks of the countdown timer on the main game window.
 void run()
          This method will be automatically called when the "scheduleAtFixedRate" or "schedule" method of the Timer class is called.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

owner

private PlusNumber owner
PlusNumber object that creates and has this TimerTask object.


sessionState

private java.lang.String sessionState
String representing the current session state.

Constructor Detail

MyTimerTask

public MyTimerTask(PlusNumber owner,
                   java.lang.String sessionState)
Constructor initialising all attributes with receiving two arguments.

Parameters:
owner - a parent PlusNumber object.
sessionState - string representing a state of a game session (either "correct" or "exceed")

MyTimerTask

public MyTimerTask(PlusNumber owner)
Constructor initialising all attributes with receiving one argument.

Parameters:
owner - a parent PlusNumber object.

MyTimerTask

public MyTimerTask()
Default constructor that initialise attributes by caling a non-default constructor.

Method Detail

run

public void run()
This method will be automatically called when the "scheduleAtFixedRate" or "schedule" method of the Timer class is called. Tasks written here will be executed after a specified duration of delay. This method switches tasks according to the value of "sessionState".

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class java.util.TimerTask

processCorrectAfterOneSecond

private void processCorrectAfterOneSecond()
This method is called by a GamePanelActionLister object when a game panel is clicked and the total sum becomes equals to a question number. A Timer object is used in order to reflesh the window after a second so that the user can read the message on the screen.


processExceedAfterOneSecond

private void processExceedAfterOneSecond()
This method is called by a GamePanelActionLister object when a game panel is clicked and the total sum exceeds a question number. A Timer object is used in order to reflesh the window after a second so that the user can read the message on the screen.


processTimer

private void processTimer()
This method defines tasks of the countdown timer on the main game window. The timer starts from "3:00" and reduces the time by second. When it reaches to "0:00", the timer will stop.