static void Main(string[] args) { PHANSO B = XuLyPhanSo.Doc("PhanSo.txt"); PHANSO A = XuLyPhanSo.Nhap("Nhap phan so :\n"); QUANHE kq = XuLyPhanSo.SoSanh(A, B); String Chuoi; Chuoi = XuLyPhanSo.XuatChuoi(A) + "kq" + XuLyPhanSo.XuatChuoi(B); if (kq == QUANHE.NhoHon) { Chuoi = Chuoi.Replace("kq", "<"); } else if (kq == QUANHE.BangNhau) { Chuoi = Chuoi.Replace("kq", "="); } else if (kq == QUANHE.LonHon) { Chuoi = Chuoi.Replace("kq", ">"); } XuLyChuoi.Xuat(Chuoi); }
public static String XuatChuoi(PHANSO x) { String Chuoi; Chuoi = x.Tu + ChuoiPhanCach + x.Mau; return(Chuoi); }
public static PHANSO Hieu(PHANSO a, PHANSO b) { PHANSO temp; temp.Tu = a.Tu * b.Mau - a.Mau * b.Tu; temp.Mau = a.Mau * b.Mau; return(temp); }
public void Ghi(PHANSO p) { StreamWriter file = new StreamWriter(filePath); file.Write($"{p.TuSo}/{p.MauSo}"); file.Close(); }
public PHANSO Doc() { StreamReader file = new StreamReader(filePath); string s = file.ReadLine(); var p = new PHANSO(s); file.Close(); return(p); }
public bool Ghi(int t, int m) { if (PHANSO.LaHopLe(t, m)) { PHANSO p = new PHANSO(t, m); var luuTruPhanSo = new LT_PHANSO(); luuTruPhanSo.Ghi(p); return(true); } return(false); }
public static Boolean KiemTraAm(PHANSO x) { if (x.Tu > 0 && x.Mau < 0) { return(true); } if (x.Tu < 0 && x.Mau > 0) { return(true); } return(false); }
public static PHANSO LonNhat(ArrayList a) { PHANSO lc = (PHANSO)a[0]; foreach (PHANSO x in a) { if (XuLyPhanSo.SoSanh(x, lc) == QUANHE.LonHon) { lc = x; } } return(lc); }
static void Main(string[] args) { ArrayList b = XuLyDayPhanSo.Doc("PhanSo.inp"); String Chuoi = "Du lieu khong hop le."; if (b != null) { PHANSO lc = XuLyDayPhanSo.LonNhat(b); Chuoi = "Day so:" + XuLyDayPhanSo.XuatChuoi(b) + "\n"; Chuoi = Chuoi + "Co phan so lon nhat la:" + XuLyPhanSo.XuatChuoi(lc) + "\n"; } XuLyChuoi.Xuat(Chuoi); }
public static String XuatChuoi(ArrayList a) { String temp = ""; for (int i = 0; i < a.Count; i++) { PHANSO x = (PHANSO)a[i]; temp = temp + XuLyPhanSo.XuatChuoi(x); if (i < a.Count - 1) { temp = temp + ChuoiPhanCach; } } return(temp); }
public static QUANHE SoSanh(PHANSO a, PHANSO b) { QUANHE temp = QUANHE.BangNhau; PHANSO h = Hieu(a, b); if (KiemTraDuong(h)) { temp = QUANHE.LonHon; } if (KiemTraAm(h)) { temp = QUANHE.NhoHon; } return(temp); }
public ServiceResult <PHANSO> TinhTong2PhanSo(int x1, int y1, int x2, int y2) { ServiceResult <PHANSO> result = new ServiceResult <PHANSO>(); if (y1 == 0 || y2 == 0) { result.IsSuccess = false; result.ErrorMessage = "Mau so phai khac khong"; return(result); } var p1 = new PHANSO(x1, y1); var p2 = new PHANSO(x2, y2); var s = p1.Cong2PhanSo(p2); result.IsSuccess = true; result.Data = s; return(result); }