示例#1
0
        public void Run(UserInput cmd)
        {
            if (cmd.args.Length > 3 || cmd.args.Length < 2)
            {
                Console.WriteLine("ERROR: Usage: a sku [numitems]");
                return;
            }
            string sku      = cmd.Args(1);
            int    numItems = 1;

            if (cmd.args.Length == 3)
            {
                try {
                    numItems = int.Parse(cmd.Args(2));
                } catch (FormatException) {
                    throw new UsageException("The number of items must be a number greater than zero.");
                }
            }
            if (numItems <= 0)
            {
                throw new UsageException("The number of items must be a number greater than zero.");
            }
            string[] skuCode = catalogue.LookupCode(sku);
            if (skuCode == null)
            {
                throw new UsageException("Product " + sku + " unknown.");
            }
            warehouse.MustStock(skuCode, numItems);
            basket.Add(sku, catalogue, numItems);
        }
示例#2
0
        public void Run(UserInput cmd)
        {
            string id = cmd.Args(1);

            if (id == null || cmd.args.Length != 2)
            {
                Console.WriteLine("ERROR: Usage: d sku");
                return;
            }
            Sku sku = catalogue.Lookup(id);

            if (sku == null)
            {
                Console.WriteLine("ERROR: product code " + id + " not found");
            }
            else
            {
                Console.WriteLine("{0}\t{1}\t£{2,5:F2}", sku.code[2], sku.title, sku.price / 100.0);
                Console.WriteLine();
                foreach (string line in sku.Description())
                {
                    Console.WriteLine(line);
                }
            }
        }
 public void Run(UserInput cmd)
 {
     if (cmd.args.Length != 5)
     {
         Console.WriteLine("ERROR: Usage: r aisle loc sku num");
         return;
     }
     if (catalogue.Lookup(cmd.Args(3)) == null)
     {
         throw new UnknownProductException(cmd.Args(3));
     }
     string[] sku = new string[] { cmd.Args(1), cmd.Args(2), cmd.Args(3) };
     try {
         int numItems = int.Parse(cmd.Args(4));
         warehouse.Replenish(sku, numItems);
     } catch (FormatException) {
         Console.WriteLine("ERROR: Usage: r sku numitems");
     }
 }