static void Main2(string[] args) { PS t1 = new PS(); PS t2 = new PS(); Console.WriteLine("Tong hai phan so"); PS tong = t1.Tong(t2); tong.Hien(); Console.WriteLine("Hieu hai phan so"); PS hieu = t1.Hieu(t2); hieu.Hien(); Console.WriteLine("Tich hai phan so"); PS tich = t1.Tich(t2); tich.Hien(); Console.WriteLine("Thuong hai phan so"); PS thuong = t1.Thuong(t2); thuong.Hien(); if (t1 > t2) { Console.WriteLine("t1>t2"); } else { Console.WriteLine("t1<=t2"); } Console.ReadKey(); }
//Quy đồng public static PS operator +(PS t1, PS t2) { PS t = new PS(); t.ts = t1.ts * t2.ms + t1.ms * t2.ts; t.ms = t1.ms * t2.ms; return(t.Rutgon()); }
//Thương public PS Thuong(PS t2) { ts = this.ts * t2.ms; ms = this.ms * t2.ts; return(Rutgon()); }
//Hiệu public PS Hieu(PS t2) { ts = this.ts * t2.ms - this.ms * t2.ts; ms = this.ms * t2.ms; return(Rutgon()); }