using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace haromszogek { class DHaromszog { private double aOldal; private double bOldal; private double cOldal; public double a { get { return aOldal; } set { if(value > 0) { aOldal = value; } else { throw new Exception(Sorszama + "Az a oldal nem lehet nulla vagy negatív!"); } } } public double b { get { return bOldal; } set { if (value > 0) { bOldal = value; } else { throw new Exception(Sorszama + "A b oldal nem lehet nulla vagy negatív!"); } } } public double c { get { return cOldal; } set { if (value > 0) { cOldal = value; } else { throw new Exception(Sorszama + "A c oldal nem lehet nulla vagy negatív!"); } } } public int Sorszama { get; set; } public bool EllNovekvoSorrend { get { return a <= b && b < c; } } public bool EllMegszerkesztheto { get { return a + b > c; } } public bool EllDerekszogu { get { return c * c == a * a + b * b; } } public double Kerület { get { return a + b + c; } } public double Terület { get { return a * b / 2; } } public DHaromszog(string sor, int sorSzama) { Sorszama = sorSzama; string[] oldalak = sor.Split(' '); a = double.Parse(oldalak[0]); b = double.Parse(oldalak[1]); c = double.Parse(oldalak[2]); if (!EllNovekvoSorrend) throw new Exception($"{Sorszama}. sor: Az adatok nincsenek növekvő sorrendben!"); if (!EllMegszerkesztheto) throw new Exception($"{Sorszama}. sor: A háromszöget nem lehet megszerkeszteni!"); if (!EllDerekszogu) throw new Exception($"{Sorszama}. sor:A háromszög nem derékszögű!"); } public override string ToString() { return $"{Sorszama}. sor: a={a} b={b} c={c}"; } } }