package Zuoe;
public class Timme {
private int hr;
private int min;
private int sec;
public void Time()
{
hr = 0;
min = 0;
sec = 0;
}
public void showTime(int h,int m,int s)
{
System.out.println(hr+":"+min+":"+sec);
}
public void addTime(int h,int m,int s)
{
int temp_m = 0,temp_h = 0;
int nHr,nMin,nSec;
if((s + sec) >= 60)
{
temp_m = min;
min++;
nSec = sec + s - 60;
}
else
{
nSec = sec + s;
}
if((min + m) >= 60)
{
temp_h = hr;
hr++;
nMin = min + m - 60;
}
else
{
nMin = min + m;
}
if((hr + h) > 24)
{
nHr = hr + h - 24;
}
else
{
nHr = hr + h;
}
hr = temp_h;
min = temp_m;
showTime(nHr,nMin,nSec);
}
public void diffTime(int h,int m,int s)
{
int temp_m = 0,temp_h = 0;
int nHr;
int nMin;
int nSec;
if(sec < s)
{
temp_m = min;
nSec = sec + 60 - s;
min--;
}
else
{
nSec = sec - s;
}
if(min < m)
{
temp_h = hr;
nMin = min + 60 - s;
hr--;
}
else
{
nMin = min - m;
}
nHr = hr - h;
hr = temp_h;
min = temp_m;
showTime(nHr,nMin,nSec);
}
}