예제 #1
0
        static void Main(string[] args)
        {
            List <ToyBox> toyboxes = new List <ToyBox>();
            string        UserAnswer;

            Console.WriteLine("Please add a toybox.");
            do
            {
                ToyBox newToyBox = GetNewToyBoxFromUser();
                toyboxes.Add(newToyBox);
                Console.WriteLine("Do you want to add another toybox? yes or no>>");
                UserAnswer = Console.ReadLine();
            } while (UserAnswer.ToLower() == "yes");


            string answer;

            foreach (ToyBox toyBox in toyboxes)
            {
                Console.WriteLine($"Time to fill {toyBox.Owner}'s Toy Box!");
                do
                {
                    Toy newToy = GetNewToyFromUser();
                    toyBox.Toys.Add(newToy);

                    Console.WriteLine("do you want to enter another toy? yes or no?>>");
                    answer = Console.ReadLine();
                } while (answer.ToLower() == "yes");
            }

            Console.WriteLine("Time to take a look at all your toys!");
            Console.WriteLine();
            foreach (ToyBox toyBox in toyboxes)
            {
                Console.WriteLine($"Content of {toyBox.Owner}'s ToyBox!");
                foreach (Toy toy in toyBox.Toys)
                {
                    Console.WriteLine(toy);
                }
            }

            foreach (ToyBox TB in toyboxes)
            {
                Console.WriteLine($"{TB.GetRandomToy().Name}");
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            List <ToyBox> toyboxes = new List <ToyBox>();


            string response = string.Empty;

            do
            {
                Console.WriteLine("What is the location of your ToyBox");
                string location = Console.ReadLine();

                Console.WriteLine("Who is the owner of your ToyBox");
                string owner = Console.ReadLine();

                ToyBox tb1 = new ToyBox()
                {
                    Location = location,
                    Owner    = owner
                };

                toyboxes.Add(tb1);

                Console.WriteLine("Do you want to start a new toybox");
                response = Console.ReadLine();
            } while (response.ToLower() == "yes");

            string answer = string.Empty;

            foreach (ToyBox toyBox in toyboxes)
            {
                do
                {
                    Console.WriteLine($"Time to fill {toyBox.Owner}'s Toy Box!");

                    Toy newToy = GetNewToyFromUser();
                    toyBox.Toys.Add(newToy);

                    Console.WriteLine("Do you want to enter another toy? yes or no");
                    answer = Console.ReadLine();
                } while (answer.ToLower() == "yes");
            }



            Console.WriteLine("Time to take a look at all your toys");

            foreach (ToyBox toyBox in toyboxes)
            {
                Console.WriteLine($"Content of {toyBox.Owner}'s ToyBox!");

                foreach (Toy toy in toyBox.Toys)
                {
                    Console.WriteLine($"\n{toy.Name} was made by {toy.Manufacturer} and cost {toy.Price} on {toy.GetAisle()} and has these notes {toy.GetNotes()}");
                }
            }

            foreach (ToyBox TB in toyboxes)
            {
                Console.WriteLine($"\n{TB.GetRandomToy().Name}");
            }
        }