Time Operator Overloading
Time Operator Overloading
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace timeOperatorOverloading
{
class Time
{
double hour;
double minute;
double sec;
this.hour = h;
this.minute = m;
this.sec = s;
}
if (s >= 60)
{
double a = s % 60;
int b = (int)s / 60;
s = a;
m = m + b;
if (m >= 60)
{
double a = m % 60;
int b = (int)m / 60;
m = a;
h = h + b;
}
if (s >= 60)
{
double a = s % 60;
int b = (int)s / 60;
s = a;
m = m + b;
}
if (m >= 60)
{
double a = m % 60;
int b = (int)m / 60;
m = a;
h = h + b;
}
if (s >= 60)
{
double a = s % 60;
int b = (int)s / 60;
s = a;
m = m + b;
if (m >= 60)
{
double a = m % 60;
int b = (int)m / 60;
m = a;
h = h + b;
}
Console.WriteLine("{0} {1} {2}", this.hour + " hours", this.minute + " minutes", this.sec
+ " seconds");
}
class Program
{
static void Main(string[] args)
{
Time t1 = new Time(12, 40, 40);
Time t2 = new Time(6, 20, 10);
}
}
}