Every time you do:
Time application = new Time(); you create a new object and therefor you reset the values back to zero.
So create only ONE object (do this once:
Time application = new Time(); )
And then use the application instance to change its values.
By the way, the Time class is totally wrong. The get, set methods are not suppose to print anything:
class Time {
private int seconds = 0;
....
....
public Time() {
}
public Time(int seconds, ......) {
this.seconds = seconds;
.....
.....
}
public int getSeconds() {
return seconds;
}
public void setSeconds(int seconds) {
this.seconds = seconds;
}
}
Now if your teacher wants the set methods to return boolean, then:
public boolean setSeconds(int seconds) {
if (seconds<0) {
return false;
}
this.seconds = seconds;
return true;
}