Untitled

mail@pastecode.io avatar
unknown
csharp
a year ago
3.1 kB
2
Indexable
namespace ConsoleApp9
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.Write("ФИО 1: ");
            string fio1 = Console.ReadLine();
            Console.Write("Дата 1: ");
            string date1 = Console.ReadLine();
            Console.Write("Средний балл 1: ");
            double gpa1 = Convert.ToDouble(Console.ReadLine());
            Console.Write("Балл за личные достижения 1: ");
            double bonus1 = Convert.ToDouble(Console.ReadLine());
            Enrollee enrolle1 = new Enrollee(fio1, gpa1, date1, bonus1);

            Console.WriteLine();

            Console.Write("ФИО 2: ");
            string fio2 = Console.ReadLine();
            Console.Write("Дата 2: ");
            string date2 = Console.ReadLine();
            Console.Write("Средний балл 2: ");
            double gpa2 = Convert.ToDouble(Console.ReadLine());
            Console.Write("Балл за личные достижения 2: ");
            double bonus2 = Convert.ToDouble(Console.ReadLine());
            Enrollee enrolle2 = new Enrollee(fio2, gpa2, date2, bonus2);

            Console.WriteLine();
            Console.WriteLine();

            Enrollee cool = enrolle1 > enrolle2;
            Console.Write("Крутой: ");
            cool.PrintData();
            Console.WriteLine($"Может поступить?: {Enroll.CanEnroll(cool)}");

            Console.WriteLine();

            Enrollee lox = enrolle1 < enrolle2;
            Console.Write("Лох: ");
            lox.PrintData();
            Console.WriteLine($"Может поступить?: {Enroll.CanEnroll(lox)}");
        }
    }

    public class Enrollee
    {
        private string fullName;
        public double gpa;
        private double bonusPoints;
        private string date;
        public Enrollee(string fullName, double gpa, string date, double bonusPoints)
        {
            this.fullName = fullName;
            this.gpa = gpa;
            this.date = date;   
            this.bonusPoints = bonusPoints;
        }

        public static Enrollee operator <(Enrollee a, Enrollee b)
        {
               if(a.gpa != b.gpa)
                   return a.gpa < b.gpa ? a : b;
               else
                   return a.bonusPoints < b.bonusPoints ? a : b;
        }

        public static Enrollee operator >(Enrollee a, Enrollee b)
        {
            if (a.gpa != b.gpa)
                return a.gpa > b.gpa ? a : b;
            else
                return a.bonusPoints > b.bonusPoints ? a : b;
        }

        public void PrintData()
        {
            Console.WriteLine($"ФИО: {fullName}, GPA: {gpa}, Дата подачи: {date}, Баллы за личные достижения: {bonusPoints}");
        }
    }

    static class Enroll
    {
        static public double gpa = 4.5;

        static public bool CanEnroll(Enrollee enrolle)
        {
            return enrolle.gpa >= gpa;
        }
    }
}