2
   

need help with java

 
 
Reply Mon 18 Feb, 2008 01:00 am
I have a project with Java, which change the clock display from a 24 hour clock to a 12 hour clock. (The code is below)
I could do it by changing the method updateDisplay, but the problem is, I have to do it without changing the method updateDisplay and class numberDisplay.
But I could modify timeTick method and clockDisplay class.

Here the zip file

I have no idea how to do it, I really need help.
Thanks in advance.

Code:
public class ClockDisplay
{
private NumberDisplay hours;
private NumberDisplay minutes;
private String displayString; // simulates the actual display

/**
* Constructor for ClockDisplay objects. This constructor
* creates a new clock set at 00:00.
*/

public ClockDisplay()
{
hours = new NumberDisplay(24);
minutes = new NumberDisplay(60);
updateDisplay();
}

/**
* Constructor for ClockDisplay objects. This constructor
* creates a new clock set at the time specified by the
* parameters.
*/

public ClockDisplay(int hour, int minute)
{
hours = new NumberDisplay(24);
minutes = new NumberDisplay(60);
setTime(hour, minute);
}

/**
* This method should get called once every minute - it makes
* the clock display go one minute forward.
*/

public void timeTick()
{
minutes.increment();
if(minutes.getValue() == 0)
{
// it just rolled over!
hours.increment();
}
updateDisplay();
}

/**
* Set the time of the display to the specified hour and
* minute.
*/

public void setTime(int hour, int minute)
{
hours.setValue(hour);
minutes.setValue(minute);
updateDisplay();
}

/**
* Return the current time of this display in the format HH:MM.
*/

public String getTime()
{
return displayString;
}


/**
* Update the internal string that represents the display.
* Do not change it
*/

private void updateDisplay()
{
displayString = hours.getDisplayValue() + ":" +
minutes.getDisplayValue();
}

}
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 2 • Views: 987 • Replies: 1
No top replies

 
rockerpham
 
  1  
Reply Mon 18 Feb, 2008 01:36 am
Here the zip file of everything
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » need help with java
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 05/03/2024 at 12:17:29