Exemplo n.º 1
0
        static void LetKidTryHisLuck(AttractionManager manager, Kid kid)
        {
            var attractionsCount = Enum.GetNames(typeof(Attractions)).Length;

            // Kid will try to go to all attractions
            for (int i = 0; i < attractionsCount; i++)
            {
                manager.TakeFee(kid, (Attractions)i);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Input day
            Console.WriteLine("Please enter day of week:");
            Days day = (Days)Convert.ToInt32(Console.ReadLine());

            // Input kids count
            Console.WriteLine("Please enter kids count:");
            int kidsCount = Convert.ToInt32(Console.ReadLine());
            // Input kids list
            List <Kid> kids = RegisterKids(kidsCount);

            //// Test pool of kids for fast debug
            //List<Kid> kids = new List<Kid>();
            //kids.Add(new Kid("Joe", Gender.male, -12, 145, -45, 100));
            //kids.Add(new Kid("Mary", Gender.female, 8, 125, 30, 90));
            //kids.Add(new Kid("Peter", Gender.male, 10, 125, 30, 20));

            // Initialize attraction manager
            AttractionManager am = new AttractionManager(day);

            while (am.GetCashBox() < 200)
            {
                // Counter for kids that spent all money
                int kidsWithNoMoney = 0;
                // Let each kid ride on attraction
                foreach (Kid k in kids)
                {
                    LetKidTryHisLuck(am, k);
                    if (k.GetCash() < 10)
                    {
                        kidsWithNoMoney++;
                    }
                }
                // If all kids are out of money - close park
                if (kidsWithNoMoney == kids.Count)
                {
                    Console.WriteLine("Kids spent all of their money...");
                    break;
                }
            }

            ClosePark(kids);
            Console.WriteLine("Money earned: {0}", am.GetCashBox());

            // Few tests to be sure that interfaces of classes are working correctly
            //// Test Kid class
            //Kid joe = new Kid("Joe", Gender.male, -12, 145, -45, -85);
            //joe.RideAttraction(Attractions.Batman, 20);
            //joe.RideAttraction(Attractions.Pony, 10);
            //joe.Cry();
            //Console.WriteLine("name: {0}\nheight: {1}\nmoney left: {2}\nsatisfaction: {3}\n\n",
            //    joe.GetName(), joe.GetHeight(), joe.GetCash(), joe.GetSatisfationLevel());

            //// Test AttractionManager class
            //AttractionManager am = new AttractionManager();
            //am.TakeFee(joe, Attractions.Batman);
            //Console.WriteLine("Cash in cashbox {0}", am.GetCashBox());
            //am.TakeFee(joe, Attractions.Pony);
            //Console.WriteLine("Cash in cashbox {0}", am.GetCashBox());

            Console.ReadLine();
        }