public void CaughtPrawn(Shrimp prawn) { if (prawns.Contains(prawn)) { return; } prawns.Add(prawn); Game.Instance.player.ShrimpCount = prawns.Count; }
void Start() { //7. 请将第4题转化为c#代码。 //======================================================实例化================================================================== Food sd = new Sardine(); Wing greywing = new Wing(); Seagull sg = new Seagull("seagull", 20, greywing, sd); Food shrimp = new Shrimp(); Wing brownwing = new Wing(); Petrel pt = new Petrel("petrel", 20, brownwing, shrimp); Food apple = new Apple(); Wing hazelwing = new Wing(); Ostrich os = new Ostrich("ostrich", 20, hazelwing, apple); //8. 请将第5题转化为c#代码。 //======================================================实例化================================================================== Human Ningning = new Human("Ningning"); Human Wuwu = new Human("wuwu"); Human Zz = new Human("zz"); FruitShop fruitShop = new FruitShop(); ClothingShop clothingShop = new ClothingShop(); Ningning.Shopping(fruitShop.Selling()); Ningning.Giving(Ningning.goods, Wuwu); Wuwu.Eat(Wuwu.goods); Ningning.Shopping(clothingShop.Selling()); Ningning.Giving(Ningning.goods, Zz); Zz.Wear(); //9. 请将第6题转化为c#代码。 //======================================================实例化================================================================== Director Baibai = new Director("baibai"); List<Developer> friends = new List<Developer> { new Developer("writer"), new Developer("charactordesigner"), new Developer("setdesigner"), new Developer("animator"), new Developer("composer"), new Developer("sounddesigner"), }; Audience dalao = new Audience(); Baibai.CallingFriends(friends); Baibai.ShowToAudience(dalao); dalao.CommentFilm(Baibai.DirectFilm()); }
void Start() { shrimp = GetComponent<Shrimp>(); animator = GetComponent<Animator>(); }
public int GetPrawnIndex(Shrimp prawn) { return(prawns.IndexOf(prawn)); }
public ActionResult CreatePizza(string size, string name, bool?bacon, bool?bbq, bool?cheese, bool?mushroom, bool?onion, bool?pepperoni, bool?pepper, bool?pineapple, bool?sausage, bool?shrimp, int amt, bool?deliver, InfoViewModel infoView) { bool isNum = IsNumber(amt); if (ModelState.IsValid && !string.IsNullOrEmpty(size) && isNum) { double totalCost; Pizza aPizza = null; //Switch statement for the size of the pizza switch (size) { case "Small": aPizza = new Small(); break; case "Medium": aPizza = new Medium(); break; case "Large": aPizza = new Large(); break; } //If the topping was selected then it is added to the pizza if (bacon == true) { aPizza = new Bacon(aPizza); } if (bbq == true) { aPizza = new BBQ(aPizza); } if (cheese == true) { aPizza = new ExCheese(aPizza); } if (mushroom == true) { aPizza = new Mushroom(aPizza); } if (onion == true) { aPizza = new Onion(aPizza); } if (pepperoni == true) { aPizza = new Pepperoni(aPizza); } if (pepper == true) { aPizza = new Peppers(aPizza); } if (pineapple == true) { aPizza = new Pineapple(aPizza); } if (sausage == true) { aPizza = new Sausage(aPizza); } if (shrimp == true) { aPizza = new Shrimp(aPizza); } //Created a variable to contain and manipulate the cost totalCost = aPizza.GetCost(); infoView.Delivery = deliver; if (Session["cart"] == null) { List <CartItem> cart = new List <CartItem> { new CartItem { ID = 1, Pizza = aPizza, Quant = amt, ViewModel = infoView } }; Session["info"] = infoView; Session["cart"] = cart; Session["Total"] = cart.Sum(item => item.Pizza.GetCost() * item.Quant); } else { List <CartItem> cart = (List <CartItem>)Session["cart"]; int index = IsExist(aPizza); if (index != -1) { cart[index].Quant++; } else { int currentID = cart.Count(); cart.Add(new CartItem { ID = currentID, Pizza = aPizza, Quant = amt, ViewModel = infoView }); } Session["info"] = infoView; Session["cart"] = cart; Session["Total"] = cart.Sum(item => item.Pizza.GetCost() * item.Quant); } //Method sends order to database //aConnection.InsertPizzaOrder(aPizza, totalCost, name, amt, deliver, addy, city, zip, time); //Adds everything to a ViewBag to send to confirmation page //ViewBag.APizza = aPizza; //ViewBag.Total = totalCost; //ViewBag.Name = name; //ViewBag.Amt = amt; //ViewBag.Deliver = deliver; //ViewBag.Addy = addy; //ViewBag.City = city; //ViewBag.Zip = zip; //ViewBag.Time = time; return(RedirectToAction("DisplayCart")); } else { if (string.IsNullOrEmpty(size)) { TempData["Amt"] = "The amount must be a number"; TempData["Size"] = "A size must be selected"; } return(View("CreatePizzaForm", infoView)); } }
public ActionResult AddMorePizza(string size, string name, bool?bacon, bool?bbq, bool?cheese, bool?mushroom, bool?onion, bool?pepperoni, bool?pepper, bool?pineapple, bool?sausage, bool?shrimp, int amt) { if (!string.IsNullOrEmpty(size)) { double totalCost; Pizza aPizza = null; //Switch statement for the size of the pizza switch (size) { case "Small": aPizza = new Small(); break; case "Medium": aPizza = new Medium(); break; case "Large": aPizza = new Large(); break; } //If the topping was selected then it is added to the pizza if (bacon == true) { aPizza = new Bacon(aPizza); } if (bbq == true) { aPizza = new BBQ(aPizza); } if (cheese == true) { aPizza = new ExCheese(aPizza); } if (mushroom == true) { aPizza = new Mushroom(aPizza); } if (onion == true) { aPizza = new Onion(aPizza); } if (pepperoni == true) { aPizza = new Pepperoni(aPizza); } if (pepper == true) { aPizza = new Peppers(aPizza); } if (pineapple == true) { aPizza = new Pineapple(aPizza); } if (sausage == true) { aPizza = new Sausage(aPizza); } if (shrimp == true) { aPizza = new Shrimp(aPizza); } //Created a variable to contain and manipulate the cost totalCost = aPizza.GetCost(); if (Session["cart"] == null) { List <CartItem> cart = new List <CartItem> { new CartItem { ID = 1, Pizza = aPizza, Quant = amt, ViewModel = (InfoViewModel)Session["info"] } }; Session["cart"] = cart; Session["Total"] = cart.Sum(item => item.Pizza.GetCost() * item.Quant); } else { List <CartItem> cart = (List <CartItem>)Session["cart"]; int index = IsExist(aPizza); if (index != -1) { cart[index].Quant++; } else { int currentID = cart.Count(); cart.Add(new CartItem { ID = currentID, Pizza = aPizza, Quant = amt, ViewModel = (InfoViewModel)Session["info"] }); } Session["cart"] = cart; Session["Total"] = cart.Sum(item => item.Pizza.GetCost() * item.Quant); } return(RedirectToAction("DisplayCart")); } else { if (string.IsNullOrEmpty(size)) { TempData["Amt"] = "The amount must be a number"; TempData["Size"] = "A size must be selected"; } return(View("AddMorePizzaForm")); } }
public void AddToppings(IOrderable pizza, string type) { switch (type) { case "1": IOrderable artichoke = new Artichoke(pizza); AddToppingsMenu(artichoke); return; case "2": IOrderable cilantro = new Cilantro(pizza); AddToppingsMenu(cilantro); return; case "3": IOrderable ham = new Ham(pizza); AddToppingsMenu(ham); return; case "4": IOrderable kebab = new Kebab(pizza); AddToppingsMenu(kebab); return; case "5": IOrderable kebabsauce = new Kebabsauce(pizza); AddToppingsMenu(kebabsauce); return; case "6": IOrderable mushroom = new Mushroom(pizza); AddToppingsMenu(mushroom); return; case "7": IOrderable mussels = new Mussels(pizza); AddToppingsMenu(mussels); return; case "8": IOrderable onion = new Onion(pizza); AddToppingsMenu(onion); return; case "9": IOrderable pineapple = new Pinapple(pizza); AddToppingsMenu(pineapple); return; case "10": IOrderable shrimp = new Shrimp(pizza); AddToppingsMenu(shrimp); return; case "y": currentOrder.ItemsOrdered.Add(pizza); PlaceOrderMenu(); return; default: Console.WriteLine("Please write the number of the topping you want."); AddToppingsMenu(pizza); return; } }