Re: JAVA 1 Class, NEED HELP
What exactly is your problem, what are you stuck on?
Re: JAVA 1 Class, NEED HELP
I am unable to get the display to read 12 instead of 00:00 for noon and midnight. Every other hour works as a 12 hour clock. I have tried making several changes in timeTick but every time I make a change a piece of timeTick stops working.
Re: JAVA 1 Class, NEED HELP
If you can only change that limited set of methods mentioned in your first post there is no sensible way of doing it. The problem is purely a data representation issue and it should be handled in the updateDisplay method.
However, you can achieve the effect you want with a bodge by constructing the hours NumberDisplay object with a value of 13 and then in the timeTick method check for the hour rolling over to 0 and immediately set it to 1.
Re: JAVA 1 Class, NEED HELP
Is this how it should look?
Code:
public void timeTick()
{
minutes.increment();
if(minutes.getValue() == 0) { // it just rolled over!
hours.increment();
}
updateDisplay();
if(updateDisplay() == 0)
return 1;
}
Re: JAVA 1 Class, NEED HELP
Have you followed my full instructions and does it compile and work?
Re: JAVA 1 Class, NEED HELP
I am not able to change the updateDisplay method due to my teachers instructions so I added the if statement to the timeTick method's updateDislay and when I try to compile it the new if statement is highlighted and I get an error saying 'void' type no allowed here. The brackets after updateDisplay are in a red box. What am I doing wrong?
Re: JAVA 1 Class, NEED HELP
updateDisplay() doesn't return anything (string or integer), and you're trying to compare it's return value to 0. Instead, you could try checking to see what the time is with a method that returns the time, getTime(), changing/setting the time as necessary, before updating the display.
Re: JAVA 1 Class, NEED HELP
I am not aloud at add any new methods.
Re: JAVA 1 Class, NEED HELP
True, but the getTime() method you included in the code returns a string value that represents the time and the setTime() method allows you to change the time.
Re: JAVA 1 Class, NEED HELP
Thank you all for your help. I got it all worked out.