Пример #1
0
 public object visit(vegetable v)
 {
     if (v.Calories < min.Calories)
     {
         min = v;
     }
     return(v.nextitem.accept(this));
 }
Пример #2
0
 public object visit(meat m) // can't be red meat!
 {
     if ((m.kind == Meattype.white) && m.Calories < min.Calories)
     {
         min = m;
     }
     return(m.nextitem.accept(this));
 }
Пример #3
0
 public object visit(fruit f)
 {
     if (f.Calories < min.Calories)
     {
         min = f;
     }
     return(f.nextitem.accept(this));
 }
Пример #4
0
        public string AddProduct(fooditem model)
        {
            //model. = DateTime.Now;
            string ret = fooditemManager.Savefooditem(model);

            if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
            {
                return(Shared.Constants.MSG_SUCCESS.Text);
            }

            return(Shared.Constants.MSG_ERROR.Text);
        }
Пример #5
0
        public void SetCart(string id, int quantity)
        {
            fooditem        objfooditem = new fooditem();
            List <fooditem> lstfooditem = fooditemManager.Getfooditem("ITEMID='" + id + "'", null);

            objfooditem.ITEMNAME = lstfooditem.First().ITEMNAME;
            objfooditem.PRICE    = lstfooditem.First().PRICE;
            Cart objcart = new Cart();

            objcart.ITEMID     = int.Parse(id);
            objcart.ITEMNAME   = objfooditem.ITEMNAME;
            objcart.PRICE      = objfooditem.PRICE;
            objcart.CUSTOMERID = GetSessionUser().CUSTID;
            objcart.QUANTITY   = quantity;
            objcart.subtotal   = objcart.QUANTITY * objcart.PRICE;
            SetSessionCart(objcart);

            //return "Success";
        }
Пример #6
0
    public static void Main(string[] args)
    {
        fruit     a = new fruit("apple", 50);
        fruit     b = new fruit("watermellon", 200);
        vegetable c = new vegetable("cabbage soup", 150, "white");
        vegetable d = new vegetable("spinach", 1000, "green");
        meat      e = new meat("chicken", Meattype.white);
        meat      f = new meat("beef", Meattype.red);

        c.nextitem = e; e.nextitem = a; a.nextitem = f;
        f.nextitem = b; b.nextitem = d;
        fooditem thefood = c; // start of list;

        // eat visitor
        eater popeye = new eater(4000); // popeye needs 4000 calories
        int   ate    = (int)thefood.accept(popeye);

        Console.WriteLine("popeye ate " + ate + " calories");

        //problem 0 visitor
        sumFoodList problem0 = new sumFoodList();

        Console.WriteLine("Problem 0 results below:");
        Console.WriteLine(c.accept(problem0));



        // healthinspector picks out healthiest food item
        healthinspector nutritionist = new healthinspector(c);
        fooditem        best         = (fooditem)thefood.accept(nutritionist);

        Console.WriteLine("nutritionist says the " + best + " is the healthiest.");


        // below is functioning problem 1 code
        beverage problem1 = new beverage("coca cola", 400);

        problem1.nextitem = c;
        Console.WriteLine("Problem 1 results below:");
        Console.WriteLine(problem1.accept(new beveragevisitor()));

        //below is functioning problem 3 code
        //c is not ordered so we expect the output to be false
        Console.WriteLine(c.accept(new islistordered()));


        //now lets construct and ordered list and test
        fruit     testfruit     = new fruit("apple", 50);;
        vegetable testvegetable = new vegetable("cabbage soup", 150, "white");;
        meat      testmeat      = new meat("chicken", Meattype.white);

        testfruit.nextitem     = testvegetable;
        testvegetable.nextitem = testmeat;
        fooditem orderedTestList = testfruit;

        // Prints out true test case passes ...on a side note this is such a small % of test cases but w.e it works
        Console.WriteLine(orderedTestList.accept(new islistordered()));



        Console.Read();
    } // Main
 // constructor must take first food cell
 public healthinspector(fooditem first)
 {
     min = first;
 }
 // can't be red meat!
 public object visit(meat m)
 {
     if ((m.kind==Meattype.white) && m.Calories<min.Calories)
     min = m;
      return m.nextitem.accept(this);
 }
 public object visit(fruit f)
 {
     if (f.Calories < min.Calories) min = f;
       return f.nextitem.accept(this);
 }
 public object visit(vegetable v)
 {
     if (v.Calories < min.Calories) min = v;
       return v.nextitem.accept(this);
 }
Пример #11
0
 // constructor must take first food cell
 public healthinspector(fooditem first)
 {
     min = first;
 }