Пример #1
0
        public static void GetMoney(Client client)
        {
            client.PrintName();
            Console.WriteLine(", пожалуйста, введите данные о товаре, который вы хотите оставить в залог:");
            Console.WriteLine("Выберите категорию товара:\n1) Недвижимость\t2) Автомобиль\t3) Бытовая техника");
            int choise = Convert.ToInt32(Console.ReadLine());

            Console.Write("Введите название товара: ");
            string name = Console.ReadLine();

            Console.Write("Примечания: "); string notation = Console.ReadLine();
            Console.Write("Введите цену товара: ");
            double cost = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine($"Отлично, комиссионные будут составлять {cost * 0.15} руб, поэтому мы можем выдать вам {0.85 * cost} руб.");

            Console.WriteLine("Вы согласны? Выберите:\n1) Да\t2) Нет");

            int choise2 = Convert.ToInt32(Console.ReadLine());

            IProduct product;

            if (choise2 == 1)
            {
                switch (choise)
                {
                case 1:
                {
                    product = new Realty(name, notation, cost);
                    break;
                }

                case 2:
                {
                    product = new Car(name, notation, cost);
                    break;
                }

                default:
                {
                    product = new Appliances(name, notation, cost);
                    break;
                }
                }
                pawnShop.Add(new PawnShop(product, client, cost));
            }
        }
Пример #2
0
        public static void ReadOnFile(string path) // чтение из файла
        {
            string line;

            using (StreamReader sr = new StreamReader(path))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    string[] arr = line.Split("%");
                    IProduct product;
                    switch (arr[0])
                    {
                    case "Бытовая техника":
                    {
                        product = new Appliances(arr);
                        break;
                    }

                    case "Автомобиль":
                    {
                        product = new Car(arr);
                        break;
                    }

                    case "Недвижимость":
                    {
                        product = new Realty(arr);
                        break;
                    }

                    default:
                    {
                        product = new Appliances(arr);
                        break;
                    }
                    }

                    Client client = new Client(sr.ReadLine());
                    arr = sr.ReadLine().Split();
                    pawnShop.Add(new PawnShop(product, client, arr));
                }
            }
        }