コード例 #1
0
ファイル: Program.cs プロジェクト: MrGriland/Lab3
        public static void Main(string[] args)
        {
            Student st1 = new Student();
            Student st2 = new Student("Вася", "Пупкин");

            Console.WriteLine("Метод ToString() : " + st1.ToString());
            Console.WriteLine("Метод Equals(st1) = :" + st2.Equals(st1));
            Console.WriteLine("Метод GetHashCode() = :" + st1.GetHashCode());
            st1.Info();
            st2.Info();

            var AnonimousStudent = new { name = "Иван", surname = "Иванов", dateOfBirth = "04072002", address = "Dormitory", phone = 375448392, faculty = "FIT", course = 2, group = 10 };

            Console.WriteLine(AnonimousStudent.name);
            Console.WriteLine(AnonimousStudent.surname);

            Console.WriteLine("Введите количество студентов: ");
            int countOfSt = Convert.ToInt32(Console.ReadLine());

            Student[] st = new Student[countOfSt];
            for (int i = 0; i < countOfSt; i++)
            {
                Console.WriteLine($"{i + 1}-й студент:");
                st[i] = new Student();
            }

            Console.WriteLine("Список студентов факультета: ");
            string faculty = Console.ReadLine();

            foreach (Student stlist in st)
            {
                if (stlist.Faculty == faculty)
                {
                    Console.WriteLine();
                    Console.WriteLine($"Имя : {stlist.Name}");
                    Console.WriteLine($"Фамилия : {stlist.Surname}");
                    Console.WriteLine($"Дата рождения : {stlist.DateOfBirth}");
                    Console.WriteLine($"Адрес : {stlist.Address}");
                    Console.WriteLine($"Номер телефона : {stlist.Phone}");
                    Console.WriteLine($"Факультет : {stlist.Faculty}");
                    Console.WriteLine($"Номер курса : {stlist.Course}");
                    Console.WriteLine($"Номер группы : {stlist.Group}");
                    Console.WriteLine();
                }
            }

            Console.WriteLine("Список студентов группы: ");
            int group = Convert.ToInt32(Console.ReadLine());

            foreach (Student stlist in st)
            {
                if (stlist.Group == group)
                {
                    Console.WriteLine();
                    Console.WriteLine($"Имя : {stlist.Name}");
                    Console.WriteLine($"Фамилия : {stlist.Surname}");
                    Console.WriteLine($"Дата рождения : {stlist.DateOfBirth}");
                    Console.WriteLine($"Адрес : {stlist.Address}");
                    Console.WriteLine($"Номер телефона : {stlist.Phone}");
                    Console.WriteLine($"Факультет : {stlist.Faculty}");
                    Console.WriteLine($"Номер курса : {stlist.Course}");
                    Console.WriteLine($"Номер группы : {stlist.Group}");
                }
            }

            Console.WriteLine("Количество студентов: {0}", Student.NumOfStudents);
            Student.InfoAboutClass();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: SelDanilEv/OOP_Lab3
 public static void Output(Student std)
 {
     Console.WriteLine();
     Console.WriteLine(std.ToString());
     Console.WriteLine(std.GetYeap());
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: Bylka-ops/css-953506
        static void Main(string[] args)
        {
            var kid1 = new Schoolkid("James", "Hope", new DateTime(2000, 8, 12), Sex.Male, 167, 45, "6 A", "summer");
            var kid2 = new Schoolkid("Molly", "Blame", new DateTime(2010, 8, 12), Sex.Male, 167, 45, "6 A", "summer");

            Console.WriteLine(kid1.Equals(kid2));
            var kid3 = new Schoolkid("James", "Hope", new DateTime(2000, 8, 12), Sex.Male, 167, 45, "6 A", "summer");

            Console.WriteLine(kid1.Equals(kid3));

            Console.WriteLine("Enter firstname:");
            var firstname = Console.ReadLine();

            Console.WriteLine("Enter lastname:");
            var lastname = Console.ReadLine();

            Console.WriteLine("Enter birthdate:");
            var birthdate = Convert.ToDateTime(Console.ReadLine());

            Console.WriteLine("Enter sex:");
            var sex = (Sex)Enum.Parse(typeof(Sex), Console.ReadLine());

            Console.WriteLine("Enter heigth:");
            var heigth = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter weigth:");
            var weigth = Convert.ToInt32(Console.ReadLine());

            var    human = new Human(firstname, lastname, birthdate, sex, heigth, weigth, 0);
            IHuman info  = human;

            Console.WriteLine("Display an additional information?(Yes/No)");
            string ans = Console.ReadLine();

            if (ans == "Yes")
            {
                Console.WriteLine(info.GetBodyMassIndex());
                human.CriminalRecord();
                human.FamilyCondition();
            }
            else if (ans == "No")
            {
                Console.WriteLine("Continue...");
            }

            Console.WriteLine("You are:\n1.Schoolkid\n2.Student\n3.Worker\n");
            int choice = Convert.ToInt32(Console.ReadLine());

            р

            switch (choice)
            {
            case 1:
            {
                Console.WriteLine("Enter grade: ");
                var grade = Console.ReadLine();
                Console.WriteLine("Enter upcoming holidays: ");
                var holidays  = Console.ReadLine();
                var schoolkid = new Schoolkid(firstname, lastname, birthdate, sex, heigth, weigth,
                                              info.GetFullYears(), grade, holidays);
                human = new Schoolkid(firstname, lastname, birthdate, sex, heigth, weigth,
                                      info.GetFullYears(), grade, holidays);
                human.InstitutionType();
                schoolkid.YourStatus();
                Console.WriteLine(schoolkid.ToString());
                break;
            }

            case 2:
            {
                Console.WriteLine("Enter your university: ");
                var university = Console.ReadLine();
                Console.WriteLine("Enter your speciality: ");
                var speciality = Console.ReadLine();
                Console.WriteLine("Enter your number og group: ");
                var groupnum = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter university year: ");
                var year = Convert.ToInt32(Console.ReadLine());

                var student = new Student(firstname, lastname, birthdate, sex, heigth, weigth,
                                          info.GetFullYears(), speciality, year, groupnum, university);
                human = new Student(firstname, lastname, birthdate, sex, heigth, weigth,
                                    info.GetFullYears(), speciality, year, groupnum, university);
                human.InstitutionType();
                student.Dormitory();
                Console.WriteLine(student.ToString());
                student.EnterAnotherUniversity();
                break;
            }

            case 3:
            {
                var worker = new Worker(firstname, lastname, birthdate, sex, heigth, weigth,
                                        info.GetFullYears());
                IPayable rise = worker;
                human = new Worker(firstname, lastname, birthdate, sex, heigth, weigth,
                                   info.GetFullYears());
                human.InstitutionType();
                worker.InformationAboutJob();
                worker.Vacation();
                Console.WriteLine(worker.ToString());
                Console.WriteLine("Set an increase or cut salaries?(set/cut/no) ");
                string answer = Console.ReadLine();
                if (answer == "set")
                {
                    Console.WriteLine("How much to increase salary: ");
                    int money = Convert.ToInt32(Console.ReadLine());
                    rise.Rise(money);
                }
                else if (answer == "cut")
                {
                    Console.WriteLine("How much to cut salary: ");
                    int money = Convert.ToInt32(Console.ReadLine());
                    rise.Lose(money);
                }
                else if (answer == "no")
                {
                    Console.WriteLine(worker.ToString());
                }

                Console.WriteLine(worker.ToString());

                break;
            }
            }

            Console.ReadKey();
        }