Beispiel #1
0
        static FullAge addFullAge()
        {
            Console.WriteLine("Enter name:");
            string name = Console.ReadLine();
            string stringAge;
            int    age;

            do
            {
                Console.WriteLine("Enter age:");
                stringAge = Console.ReadLine();
            } while (!checkAge(stringAge) || int.Parse(stringAge) < 14);
            age = int.Parse(stringAge);
            string stringWeight;
            int    weight;

            do
            {
                Console.WriteLine("Enter weight:");
                stringWeight = Console.ReadLine();
            } while (!checkWeight(stringWeight));
            weight = int.Parse(stringWeight);
            string passportNumber;

            do
            {
                Console.WriteLine("Enter passport number (length should be 10 symbols):");
                passportNumber = Console.ReadLine();
            } while (!checkPassport(passportNumber));
            FullAge newOne = new FullAge(name, age, weight, passportNumber);

            return(newOne);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //FullAge Dima = new FullAge("Dima", 19, 70);
            //Console.WriteLine(Dima);
            List <FullAge> fullAges = new List <FullAge> {
            };
            List <Human> humen      = new List <Human> {
            };
            int input;

            do
            {
                Console.WriteLine("Enter 1 to add new fullage");
                Console.WriteLine("Enter 2 to add new Human");
                Console.WriteLine("Enter 0 to exit the program ");
                input = int.Parse(Console.ReadLine());
                switch (input)
                {
                case 1:
                    FullAge newFullAge = addFullAge();
                    fullAges.Add(newFullAge);
                    break;

                case 2:
                    Human newHuman = addHuman();
                    humen.Add(newHuman);
                    break;

                case 0:
                    break;

                default:
                    Console.WriteLine("Wrong input, please try again");
                    break;
                }
            } while (input != 0);
            foreach (FullAge oneFullAge in fullAges)
            {
                Console.WriteLine(oneFullAge);
            }
        }