static void Main(string[] args) { WeddingCake MyClasses = new WeddingCake(); MyClasses.MyMethod(new WeddingCake()); BirthdayCake <string> Module = new BirthdayCake <string>(); Module.Flavor = "Chocolate"; Console.WriteLine("I don't like my birthday cake because it has the flavor of " + Module.Flavor); Console.WriteLine("My favorite flavor is" + MyClasses); }
/// <summary> /// Loads all crops from old file /// </summary> public void LoadOldCrops() { //Checks to see if the file exists if (File.Exists("CropsLayout.txt")) { //Reads the file if it does exist uses that info to set up crop layout and create crop objects using (StreamReader input = new StreamReader("CropsLayout.txt")) { while (input.Peek() != -1) { int daysGrown; bool isFullGrown; string cropType; int x; int y; cropType = input.ReadLine(); //read the line to determine if the crop is fully grown, and make it a boolean //MIGHT HAVE TO CHANGE IF I JUST WRITE FALSE WILL IT WORK IN THE LOAD Boolean.TryParse(input.ReadLine(), out isFullGrown); //read the line to determine the days grown, and make it an integer int.TryParse(input.ReadLine(), out daysGrown); int.TryParse(input.ReadLine(), out x); int.TryParse(input.ReadLine(), out y); if (cropType == "Pumpkin") { _cropsLayout[x, y] = new Pumpkin(daysGrown, x, y, isFullGrown); } else if (cropType == "Radish") { _cropsLayout[x, y] = new Radish(daysGrown, x, y, isFullGrown); } else if (cropType == "WeddingCake") { _cropsLayout[x, y] = new WeddingCake(daysGrown, x, y, isFullGrown); } } } } }
public static void InitInteractions(GameObject obj) { ServingContainer container = obj as ServingContainer; if (container != null) { // EA fail container.RemoveInteractionByType(ServingContainerGroup.CallToMeal.Singleton); } WeddingCake cake = obj as WeddingCake; if (cake != null) { cake.RemoveInteractionByType(WeddingCake.CutWeddingCake.Singleton); } Snack container2 = obj as Snack; if (container2 != null) { if (obj != null) { obj.RemoveInteractionByType(CraftersConsignment.ChildObjectBrowseStub.Singleton); obj.RemoveInteractionByType(CraftersConsignment.ChildObjectPurchaseStub.Singleton); obj.AddInteraction(CraftersConsignment.ChildObjectBrowseStub.Singleton); obj.AddInteraction(CraftersConsignment.ChildObjectPurchaseStub.Singleton); obj.RemoveInteractionByType(Sims3.Gameplay.Objects.CookingObjects.Eat.Singleton); obj.RemoveInteractionByType(Snack_CleanUp.Singleton); } ISpoilable spoil = container2 as ISpoilable; if (spoil != null) { spoil.UpdateSpoilageTime(true, -1f); } } }
static void Main(string[] args) { Console.WriteLine("-------Adapter DEMO:-------"); Console.WriteLine("Let's make standard cake:"); Cake cake = new Cake(); cake.RequestToMakeCake(); // Create adapter and place a request Console.WriteLine("Let's make special cake for our special allergic client:"); Cake allergicCake = new AdapterCake(); allergicCake.RequestToMakeCake(); Console.WriteLine(); Console.WriteLine("-------Bridge DEMO:-------"); // make birthday cake CakeForEvent cakeForEvent = new BirthdayCake(new CandyGift()); cakeForEvent.MakeEventCake(); Console.WriteLine(cakeForEvent.MakeEventCake() + " with gift-> " + cakeForEvent.AddGiftForEvent()); // make wedding cake cakeForEvent = new WeddingCake(new CandyGift()); cakeForEvent.Gift = new BisciutGift(); cakeForEvent.MakeEventCake(); Console.WriteLine(cakeForEvent.MakeEventCake() + " with gift-> " + cakeForEvent.AddGiftForEvent()); Console.WriteLine(); Console.WriteLine("-------Decorator DEMO:-------"); CreamCake napoleon = new Napoleon(); napoleon = new MilkCream(napoleon); Console.WriteLine("Name: {0}", napoleon.Name); Console.WriteLine("Price: {0}", napoleon.GetCost()); CreamCake kiev = new Kiev(); kiev = new ChocoCream(kiev); Console.WriteLine("Name: {0}", kiev.Name); Console.WriteLine("Price: {0}", kiev.GetCost()); CreamCake kievSpecial = new Kiev(); kievSpecial = new MilkCream(kievSpecial); kievSpecial = new ChocoCream(kievSpecial); Console.WriteLine("Name: {0}", kievSpecial.Name); Console.WriteLine("Price: {0}", kievSpecial.GetCost()); Console.WriteLine(); Console.WriteLine("-------Facade DEMO:-------"); Flakes flakes = new Flakes(); Cream cream = new Cream(); Pastry pastry = new Pastry(); PieMakerFacade pieMaker = new PieMakerFacade(cream, flakes, pastry); Console.WriteLine("Let's make our cake"); pieMaker.MakeCake(); Console.WriteLine("Let's decorate our cake"); pieMaker.DecorateCake(); Console.WriteLine(); Console.WriteLine("-------Flyweight DEMO:-------"); string[] flowers = { "RedFlower", "WhiteFlower", "WhiteFlower", "WhiteFlower" }; DecorationFlowerFactory factory = new DecorationFlowerFactory(); // For each flower use a flyweight object foreach (string flower in flowers) { DecorationFlower decorationFlower = factory.GetDecorationFlowers(flower); decorationFlower.DisplaySize(); } }