Esempio n. 1
0
        static void Main(string[] args)
        {
            ToyBox ToyBox1 = new ToyBox();
            Toy    Toy1    = new Toy();

            Toy1.Manufacturer = "Barbie";
            Toy1.Name         = "Doctor Barbie";
            Toy1.Price        = 14.99;
            Toy1.GetAisle();
            Toy1.GetAisle2();

            Console.WriteLine($"The manufacturer of Toy1 is {Toy1.Manufacturer}");
            Console.WriteLine($"The name of Toy1 is {Toy1.Name}");
            Console.WriteLine($"The price of Toy1 is {Toy1.Price}");
            Console.WriteLine($"Toy1 is found on Aisle {Toy1.GetAisle()} {Toy1.GetAisle2()}");

            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string response;
            Toy    Toy1 = new Toy();

            do
            {
                Console.WriteLine("Please input the name of the toy.");
                Toy1.Name.Add(Console.ReadLine());

                Console.WriteLine("What is the price of the toy?");
                Toy1.Price.Add(Console.ReadLine());

                Console.WriteLine("Do you have another toy to add?");
                response = Console.ReadLine();
            } while (response.ToUpper() == "YES");



            Console.ReadKey();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter the name of the toy you are looking for");
            string name = Console.ReadLine();

            Console.WriteLine("\nPlease enter the name of the manufacturer");
            string manufacturer = Console.ReadLine();

            Console.WriteLine("\nPlease enter the price");
            double price = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("\nPlease enter any special notes");
            string notes = Console.ReadLine();

            Toy newToy = new Toy();

            Console.WriteLine(newToy);



            Console.ReadKey();
        }
Esempio n. 4
0
        public void AddToy(Toy newToy)
        {
            toysList.Add(newToy);
            onToyAdded?.Invoke();
            try
            {
                if (toysList.Count > 1)
                {
                    onValueIncrease?.Invoke();
                    foreach (Toy toy in toysList)
                    {
                        sum += toy.ActualValue;
                    }
                }

                if (sum > limit)
                {
                    onLimitReached?.Invoke();
                }
            }
            catch (System.InvalidOperationException ex)
            {
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Random random = new Random();

            List <Book>           books     = new List <Book>();
            List <Toy>            toys      = new List <Toy>();
            List <SportInventory> inventory = new List <SportInventory>();

            for (int i = 0; i < random.Next(1, 100); i++)
            {
                Book           book = new Book();
                Toy            toy  = new Toy();
                SportInventory item = new SportInventory();

                book.Name         = string.Format("Book_{0}", random.Next(1, 30));
                book.Cost         = random.Next(1, 10000);
                book.Author       = string.Format("Author_{0}", random.Next(1, 30));
                book.Manufacturer = string.Format("Publisher_{0}", random.Next(1, 30));
                book.Age          = DateTime.Now.AddDays(random.Next(10000));

                toy.Name         = string.Format("Toy_{0}", random.Next(1, 30));
                toy.Cost         = random.Next(1, 10000);
                toy.Manufacturer = string.Format("Manufacturer_{0}", random.Next(1, 30));
                toy.Material     = string.Format("Material_{0}", random.Next(1, 30));
                toy.Age          = DateTime.Now.AddDays(random.Next(10000));

                item.Name         = string.Format("SportItem_{0}", random.Next(1, 30));
                item.Cost         = random.Next(1, 10000);
                item.Manufacturer = string.Format("Manufacturer_{0}", random.Next(1, 30));
                item.Age          = DateTime.Now.AddDays(random.Next(10000));


                books.Add(book);
                toys.Add(toy);
                inventory.Add(item);
            }


            Console.WriteLine("Какой тип товара вы ищите?");
            Console.WriteLine("1. Игрушки");
            Console.WriteLine("2. Книги");
            Console.WriteLine("3. Спорт. инвентарь");
            int choise = int.Parse(Console.ReadLine());

            Console.WriteLine(" -- Результат поиска -- ");

            switch (choise)
            {
            case 1:
            {
                Console.WriteLine("-----------------------------");
                Console.WriteLine("Игрушки:");
                foreach (Toy toy in toys)
                {
                    toy.ShowInfo();
                }
            }
            break;

            case 2:
                Console.WriteLine("-----------------------------");
                Console.WriteLine("Книги:");
                foreach (Book book in books)
                {
                    book.ShowInfo();
                }
                break;

            case 3:
                Console.WriteLine("-----------------------------");
                Console.WriteLine("Спорт. инвентарь:");
                foreach (SportInventory item in inventory)
                {
                    item.ShowInfo();
                }
                break;

            default:
            {
                Console.WriteLine("Такого у нас нет");
            }
            break;
            }
        }