Ejemplo n.º 1
0
        static void Main()
        {
            bool   cycle_check = true;
            int    switcher, temp, age, type;
            string name = " ", surname = " ", time, country, teacher, school;

            Human        Man     = new Human(null, null);
            DrugsAddicts NNMan   = new DrugsAddicts(null, null);
            Athletes     Olympic = new Athletes(null, null, 1);
            Schoolkids   Normpoc = new Schoolkids(null, null);

            Human[] Peoples = new Human[] { Man, NNMan, Normpoc, Olympic };

            do
            {
                Console.Clear();
                Console.WriteLine("MENU:" +
                                  "\n1 - Create Human" +
                                  "\n2 - Create Human with addicts from grugs" +
                                  "\n3 - Create Athlet" +
                                  "\n4 - Create School kid" +
                                  "\n5 - Sort" +
                                  "\n6 - Show Student Info" +
                                  "\nAny other key - exit from program");//menu

                switcher = Convert.ToInt32(Console.ReadLine());

                if (switcher < 5 && switcher >= 1)
                {
                    Console.WriteLine("Enter your Full name");
                    name    = Console.ReadLine();
                    surname = Console.ReadLine();
                }


                switch (switcher)
                {
                case 1: Man = new Human(name, surname);
                    Console.WriteLine("Enter your temperament" +
                                      " 1 - Choleric" +
                                      " 2 - Sanguine" +
                                      " 3 - Phlegmatic" +
                                      " 4 - Melancholy");
                    temp = Convert.ToInt32(Console.ReadLine());
                    switch (temp)
                    {
                    case 1: Man.Set(Human.Temperament.Choleric); break;

                    case 2: Man.Set(Human.Temperament.Sanguine); break;

                    case 3: Man.Set(Human.Temperament.Phlegmatic); break;

                    case 4: Man.Set(Human.Temperament.Melancholy); break;

                    default: Console.WriteLine("Wrong Enter"); break;
                    }
                    Console.WriteLine("Enter your age");
                    age        = Convert.ToInt32(Console.ReadLine());
                    Man._age   = age;
                    Man._expir = age;
                    break;

                case 2: Console.WriteLine("Enter for how long time you use drugs?");
                    time           = Console.ReadLine();
                    NNMan          = new DrugsAddicts(time, null);
                    NNMan._name    = name;
                    NNMan._surName = surname;
                    Console.WriteLine("Enter type of drugs" +
                                      " 1 - Opium" +
                                      " 2 - Cannabis" +
                                      " 3 - Amphetamine" +
                                      " 4 - Ecstasy");
                    type = Convert.ToInt32(Console.ReadLine());
                    switch (type)
                    {
                    case 1: NNMan.SetType(DrugsAddicts.Drugs.Opium, DrugsAddicts.Drugs.Opium);  break;

                    case 2: NNMan.SetType(DrugsAddicts.Drugs.Cannabis, DrugsAddicts.Drugs.Cannabis); break;

                    case 3: NNMan.SetType(DrugsAddicts.Drugs.Amphetamine, DrugsAddicts.Drugs.Amphetamine); break;

                    case 4: NNMan.SetType(DrugsAddicts.Drugs.Ecstasy, DrugsAddicts.Drugs.Ecstasy); break;

                    default: Console.WriteLine("Error input"); break;
                    }
                    Console.WriteLine("Enter your age");
                    age        = Convert.ToInt32(Console.ReadLine());
                    NNMan._age = age;
                    break;

                case 3: Console.WriteLine("Enter your country, sport type and expirience");
                    country = Console.ReadLine();
                    time    = Console.ReadLine();
                    type    = Convert.ToInt32(Console.ReadLine());
                    Olympic = new Athletes(country, time, type);
                    break;

                case 4: Console.WriteLine("Enter Name of your teacher and name of your school");
                    teacher          = Console.ReadLine();
                    school           = Console.ReadLine();
                    Normpoc          = new Schoolkids(teacher, school);
                    Normpoc._name    = name;
                    Normpoc._surName = surname;
                    Console.WriteLine("Enter the class your visiting(1 - A, 2 - B, 3 - C)");
                    type = Convert.ToInt32(Console.ReadLine());
                    Normpoc.SetClass(type, false, false);
                    Console.WriteLine("Enter what class you attend");
                    age            = Convert.ToInt32(Console.ReadLine());
                    Normpoc._expir = age;
                    break;

                case 5: Peoples = new Human[] { Man, NNMan, Normpoc, Olympic };
                    Array.Sort(Peoples); break;

                case 6: for (int i = 0; i < 4; i++)
                    {
                        Peoples[i].Show();
                    }
                    ; break;

                default: cycle_check = false; Console.WriteLine("Program ends"); Environment.Exit(0); break;
                }
                Console.WriteLine("Do you want ot change some information? (1 = yes, any other symbol = no)");
                switcher = Convert.ToInt32(Console.ReadLine());

                switch (switcher)
                {
                case 1: Console.WriteLine("Restart this program, a have no time to add this ability in this cycle"); break;

                default: Console.WriteLine("OK"); break;
                }
            }while (cycle_check);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            Console.WriteLine(@"Choose 1 of 3 classes:
1) DrugsAbilities
2) Athletes
3) SchoolKids");
            string dependency;
            string sporttype, country;
            string teachname, schoolname;
            int    expirience;
            int    temp;
            bool   math, science;
            int    numclass;
            int    Swicther = Convert.ToInt32(Console.ReadLine());

            switch (Swicther)
            {
            case 1:
                Console.WriteLine("Enter your Dependecy time(years):");
                dependency = Console.ReadLine();
                DrugsAddicts First = new DrugsAddicts(dependency, "0");
                Console.WriteLine("Enter the drug you started with and you use now 1) Opium, 2) Cannabis, 3) Amphetamine, 4) Ecstasy ");
                Swicther = Convert.ToInt32(Console.ReadLine());
                if (Swicther == 1)
                {
                    First.SetType(DrugsAddicts.Drugs.Opium, DrugsAddicts.Drugs.Opium);
                }
                if (Swicther == 2)
                {
                    First.SetType(DrugsAddicts.Drugs.Cannabis, DrugsAddicts.Drugs.Cannabis);
                }
                if (Swicther == 3)
                {
                    First.SetType(DrugsAddicts.Drugs.Amphetamine, DrugsAddicts.Drugs.Amphetamine);
                }
                if (Swicther == 4)
                {
                    First.SetType(DrugsAddicts.Drugs.Ecstasy, DrugsAddicts.Drugs.Ecstasy);
                }
                First.ShowInfo();
                Console.WriteLine("Enter index(from 1 to 4) for indexator");
                int index = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine($"Your choice: {First[index]}");
                break;

            case 2:
                Console.WriteLine("Enter country, sporttype end expirience(years)");
                country    = Console.ReadLine();
                sporttype  = Console.ReadLine();
                expirience = Convert.ToInt32(Console.ReadLine());
                Athletes Second = new Athletes(country, sporttype, expirience);
                Console.WriteLine("Choose your temperament(1.Choleric 2.Sanguine 3.Phlegmatic 4. Melancholy) ");
                temp = Convert.ToInt32(Console.ReadLine());
                if (temp == 1)
                {
                    Second.Set(Human.Temperament.Choleric);
                }
                if (temp == 2)
                {
                    Second.Set(Human.Temperament.Sanguine);
                }
                if (temp == 3)
                {
                    Second.Set(Human.Temperament.Phlegmatic);
                }
                if (temp == 4)
                {
                    Second.Set(Human.Temperament.Melancholy);
                }
                Second.ShowTemp();
                Second.ShowInfo();
                break;

            case 3:
                Console.WriteLine("Enter your teacher name and your school name:");
                teachname  = Console.ReadLine();
                schoolname = Console.ReadLine();
                Schoolkids Third = new Schoolkids(teachname, schoolname);
                Console.WriteLine("Enter number of class and say if u attend math or science class");
                numclass = Convert.ToInt32(Console.ReadLine());
                science  = Convert.ToBoolean(Console.ReadLine());
                math     = Convert.ToBoolean(Console.ReadLine());
                Third.SetClass(numclass, math, science);
                Third.Show();
                break;

            default:
                Console.WriteLine("Error choose, program will be closed");
                break;
            }
        }