package time;
public class Tiempo {
int hora;
int min;
int seg;
public Tiempo() {
this.hora = 0;
this.min = 0;
this.seg = 0;
}
public Tiempo(int hora, int min, int seg) {
this.hora = hora;
this.min = min;
this.seg = seg;
}
public int getHora() {
return hora;
}
public void setHora(int hora) {
this.hora = hora;
}
public int getMin() {
return min;
}
public void setMin(int min) {
this.min = min;
}
public int getSeg() {
return seg;
}
public void setSeg(int seg) {
this.seg = seg;
}
@Override
public String toString() {
return "Tiempo{" + "hora=" + hora + ", min=" + min + ", seg=" + seg + '}';
}
public String mostrarE() {
if (this.hora == 0)
return "Hora estándar es: " + "12" + ":" + this.min + ":" + this.seg + " a.m";
else
if (this.hora >=0 && this.hora < 12)
return "Hora estándar es: " + this.hora + ":" + this.min + ":" + this.seg + " a.m";
else
if (this.hora > 12)
return "Hora estándar es: " + (this.hora-12) + ":" + this.min + ":" + this.seg + " p.m";
return null;
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.