コード例 #1
0
ファイル: Controller.cs プロジェクト: pareion/TonsOfFun
        internal void addOrder()
        {
            int customerID = 0, productID = 0, quantity = 0;
            string ordreDato;
            Customer customer;
            Product product;
            newCustomerId:
            try
            {
                Console.WriteLine("What customer ID?");
                customerID = int.Parse(Console.ReadLine());
                customer = per.findCustomerWithIndexX(customerID);
                if (customer == null)
                {
                    Console.WriteLine("There is no such customer");
                    goto newCustomerId;
                }
            }
            catch (Exception)
            {
                goto newCustomerId;
            }

            newProductId:
            try
            {
                Console.WriteLine("What product ID?");
                productID = int.Parse(Console.ReadLine());
                product = findProductId(productID);
                if (product == null)
                {
                    Console.WriteLine("There is no such product");
                    goto newProductId;
                }
            }
            catch (Exception)
            {
                goto newProductId;
            }

            quantity:
            try
            {
                Console.WriteLine("How many?");
                quantity = int.Parse(Console.ReadLine());
            }
            catch (Exception)
            {
                goto quantity;
            }

            date:
            try
            {
                Console.WriteLine("When?");
                ordreDato = Console.ReadLine();
            }
            catch (Exception)
            {
                goto date;
            }
            Order order = new Order(ordreDato, quantity, customer, product);
            customer.AddOrderToList(order);
        }
コード例 #2
0
ファイル: Customer.cs プロジェクト: pareion/TonsOfFun
 public void AddOrderToList(Order order)
 {
     ordreList.Add(order);
 }