예제 #1
0
        static void Main()
        {
            List <Citizens> citizens = new List <Citizens>();
            List <Robots>   robots   = new List <Robots>();
            List <Pet>      pets     = new List <Pet>();

            Events happening = new Events();

            Console.WriteLine("Input Citizens, Robots and/or Pets: ");
            string[] start = Console.ReadLine().Split(" ");

            while (start[0] != "End")
            {
                if (start[0] == "Citizen")
                {
                    Citizens t = new Citizens(start[1], int.Parse(start[2]), start[3], start[4]);
                    citizens.Add(t);
                }
                else if (start[0] == "Robot")
                {
                    Robots t = new Robots(start[1], start[2]);
                    robots.Add(t);
                }
                else if (start[0] == "Pet")
                {
                    Pet t = new Pet(start[1], start[2]);
                    pets.Add(t);
                }
                else
                {
                    Console.WriteLine("Invalid name!");
                }

                start = Console.ReadLine().Split(" ");
            }
            Console.WriteLine("Year of birth");
            string dateOfYear = Console.ReadLine();

            for (int i = 0; i < citizens.Count; i++)
            {
                happening.wantedYear += citizens[i].YearIs;
                happening.Counter(dateOfYear);
                happening.wantedYear -= citizens[i].YearIs;
            }

            for (int i = 0; i < pets.Count; i++)
            {
                happening.wantedYear += pets[i].YearIs;
                happening.Counter(dateOfYear);
                happening.wantedYear -= pets[i].YearIs;
            }
        }
예제 #2
0
        static void Main()
        {
            List <Citizens> citizens = new List <Citizens>();
            List <Robots>   robots   = new List <Robots>();

            Console.WriteLine("Input Citizens and/or Robots: ");
            string[] start = Console.ReadLine().Split(" ");

            while (start[0] != "End")
            {
                if (start.Length == 3)
                {
                    Citizens t = new Citizens(start[0], int.Parse(start[1]), start[2]);
                    citizens.Add(t);
                }
                else if (start.Length == 2)
                {
                    Robots t = new Robots(start[0], start[1]);
                    robots.Add(t);
                }

                start = Console.ReadLine().Split(" ");
            }
            Console.WriteLine("Input Fake ID");
            string fakeID = Console.ReadLine();

            for (int i = 0; i < citizens.Count; i++)
            {
                citizens[i].Detaine(fakeID);
            }

            for (int i = 0; i < robots.Count; i++)
            {
                robots[i].Detaine(fakeID);
            }
        }
예제 #3
0
        public static void ParseInput(List <IBirthday> birthdays)
        {
            var input = Console.ReadLine();

            while (input.ToLower() != "end")
            {
                string[] InputPart = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                switch (InputPart[0].ToLower())
                {
                case "citizen":
                    IBirthday citizen = new Citizens(InputPart[1], InputPart[2], InputPart[3], InputPart[4]);
                    birthdays.Add(citizen);
                    break;

                case "pet":
                    IBirthday pet = new Pet(InputPart[1], InputPart[2]);
                    birthdays.Add(pet);
                    break;
                }

                input = Console.ReadLine();
                Console.ReadLine();
            }
        }