class apples
{
public static void main(String args[])
{
tuna tunaObj0=new tuna();
tuna tunaObj1=new tuna(5);
tuna tunaObj2=new tuna(5,13);
tuna tunaObj3=new tuna(5,13,43);
System.out.printf("%s\n",tunaObj0.toMiitary());
System.out.printf("%s\n",tunaObj1.toMiitary());
System.out.printf("%s\n",tunaObj2.toMiitary());
System.out.printf("%s\n",tunaObj3.toMiitary());
}
}
public class tuna
{
private int hour;
private int minute;
private int second;
public tuna()
{
this(0,0,0);
}
public tuna(int h)
{
this(h,0,0);
}
public tuna(int h,int m)
{
this(h,m,0);
}
public tuna(int h,int m,int s)
{
setTime(h,m,s);
}
public void setTime(int h,int m,int s)
{
hour=((h>=0&&h<24)?h:0);
minute=((m>=0&&m<60)?m:0);
second=((s>=0&&h<60)?s:0);
}
public String toMiitary()
{
return String.format("%02d:%02d:%02d",hour,minute,second);
}
}
{
public static void main(String args[])
{
tuna tunaObj0=new tuna();
tuna tunaObj1=new tuna(5);
tuna tunaObj2=new tuna(5,13);
tuna tunaObj3=new tuna(5,13,43);
System.out.printf("%s\n",tunaObj0.toMiitary());
System.out.printf("%s\n",tunaObj1.toMiitary());
System.out.printf("%s\n",tunaObj2.toMiitary());
System.out.printf("%s\n",tunaObj3.toMiitary());
}
}
public class tuna
{
private int hour;
private int minute;
private int second;
public tuna()
{
this(0,0,0);
}
public tuna(int h)
{
this(h,0,0);
}
public tuna(int h,int m)
{
this(h,m,0);
}
public tuna(int h,int m,int s)
{
setTime(h,m,s);
}
public void setTime(int h,int m,int s)
{
hour=((h>=0&&h<24)?h:0);
minute=((m>=0&&m<60)?m:0);
second=((s>=0&&h<60)?s:0);
}
public String toMiitary()
{
return String.format("%02d:%02d:%02d",hour,minute,second);
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.