import java.text.*; public class relogio { // instance variables - replace the example below with your own private int hora, minuto, segundo; public relogio() { hora = minuto = segundo = 0; } public relogio(String hora) { String [] val = hora.split(":"); this.hora=Integer.valueOf(val[0]); this.minuto=Integer.valueOf(val[1]); this.segundo=Integer.valueOf(val[2]); } public relogio(int hora, int minuto, int segundo) { this.hora=hora; this.minuto=minuto; this.segundo=segundo; } public void avancaAlgunsSegundos(int nSegundos){ for(int i=0; i=60) { segundo=0; if(minuto+1>=60){ minuto=0; if(hora+1 >=24) hora=0; else hora++; } else minuto++; } else segundo++; } public int getHora() { return hora; } public int getMinuto() { return minuto; } public int getSegundo() { return segundo; } public String toString(){ String texto=""; DecimalFormat df = new DecimalFormat("00"); texto=df.format(hora)+":"+df.format(minuto)+":"+df.format(segundo); return texto; } }