示例#1
0
 public Service_mode(Product[] product1,MoneyType[] change1)
 {
     Form1 frm = (Form1)this.Owner;
     money = new Money(this);
     InitializeComponent();
     this.product = product1;
     this.change = change1;
 }
 public void AddProduct(Product product, int quantity)
 {
     if(this.storage.ContainsKey(product)) {
         this.storage[product] += quantity;
     }
     else
     {
         this.storage.Add(product, quantity);
     }
 }
 public int Give(Product product)
 {
     if(storage[product] > 0)
     {
         storage[product]--;
         return product.Price ;
     }
     else
     {
         throw new NotEnoughProductException();
     }
 }
示例#4
0
 public void AddProduct(Product product,int quantity)
 {
     this.storage.AddProduct(product,quantity);
 }
示例#5
-2
        int type; // profuct type

        #endregion Fields

        #region Constructors

        public Form1()
        {
            InitializeComponent();

            type = 0;
            insert_money = new Money(this);
            service1 = new Service_mode(product, change);

            //initialising product array
            product[0] = new Product(4, 0.5, "Coke");
            product[1] = new Product(4, 0.5, "Sprite");
            product[2] = new Product(4, 0.4, "Mirinda");
            product[3] = new Product(4, 0.4, "Pepsi");
            product[4] = new Product(4, 0.65, "Schweppes");
            product[5] = new Product(4, 0.65, "Mountain Dew");

            //initialising the change array
            change[0] = new MoneyType(0.01, 4);
            change[1] = new MoneyType(0.02, 4);
            change[2] = new MoneyType(0.05, 4);
            change[3] = new MoneyType(0.1, 4);
            change[4] = new MoneyType(0.2, 4);
            change[5] = new MoneyType(0.5, 4);
            change[6] = new MoneyType(1, 4);
            change[7] = new MoneyType(2, 4);
        }