public void RefrigeratorTestTwo() { Refrigerator refrigerator = new Refrigerator(); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); LadyFinger ladyFinger = new LadyFinger(); refrigerator.AddVegetable(tomato, 25); refrigerator.SetVegetableMinimumQuantity(tomato, 10); refrigerator.AddVegetable(cabbage, 10); refrigerator.SetVegetableMinimumQuantity(cabbage, 2); refrigerator.AddVegetable(ladyFinger, 7); refrigerator.SetVegetableMinimumQuantity(ladyFinger, 2); refrigerator.TakeOutVegetable(tomato, 20); refrigerator.TakeOutVegetable(cabbage, 7); var actualVegetableQuantity = refrigerator.CheckRefrigeratorContents(); var expectedVegetableQuantity = new List <KeyValuePair <Vegetable, int> >(); expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(tomato, 5)); expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(cabbage, 3)); expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(ladyFinger, 7)); Assert.Equal(expectedVegetableQuantity, actualVegetableQuantity); }
public ModelView(int numberOfLeaves) { Cabbage = new Cabbage() { Leaves = numberOfLeaves } }
public void VegetableTrackerTest() { VegetableTracker vegetableTracker = new VegetableTracker(); ConfigurationManager configurationManager = new ConfigurationManager(StorageFactory.GetStorage("inMemory")); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); LadyFinger ladyFinger = new LadyFinger(); var vegetableQuantity = new List <KeyValuePair <Vegetable, int> >(); vegetableQuantity.Add(new KeyValuePair <Vegetable, int>(tomato, 25)); vegetableQuantity.Add(new KeyValuePair <Vegetable, int>(cabbage, 3)); vegetableQuantity.Add(new KeyValuePair <Vegetable, int>(ladyFinger, 2)); configurationManager.SetMinimumQuantity(tomato, 5); configurationManager.SetMinimumQuantity(cabbage, 5); configurationManager.SetMinimumQuantity(ladyFinger, 5); var expectedInsufficientVegetables = new List <KeyValuePair <Vegetable, int> >(); expectedInsufficientVegetables.Add(new KeyValuePair <Vegetable, int>(cabbage, 3)); expectedInsufficientVegetables.Add(new KeyValuePair <Vegetable, int>(ladyFinger, 2)); var actualInsufficientVegetables = vegetableTracker.GetInsufficientVegetableQuantity(vegetableQuantity, configurationManager); Assert.Equal(expectedInsufficientVegetables, actualInsufficientVegetables); }
static void Main() { // Список левого берега // Список правого берега // Добавляем в левый берег объекты // Старт игры // Выбираем объект для перевозки // Помещаем его на лодку // Сравниваем все объекты на берегах // Если нет проблем, то перемещаем // Иначе игра завершается Cabbage cabbage = new Cabbage(); Goat goat = new Goat(); goat.WriteGameObjectThatCanEat(cabbage); Wolf wolf = new Wolf(); wolf.WriteGameObjectThatCanEat(goat); GameObject[] gameObjects = new GameObject[] { cabbage, goat, wolf }; Game game = new Game(); game.LoadGameObjects(gameObjects); game.StartTheGame(); }
public void Chop(Mobile from) { if (from.InRange(this.GetWorldLocation(), 1)) { if (from == m_sower) { from.Direction = from.GetDirectionTo(this); double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100; if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue)) { Cabbage fruit = new Cabbage(Utility.Random(m_yield + 2)); from.AddToBackpack(fruit); } this.Delete(); from.SendMessage("You chop the plant up"); } else { from.SendMessage("You do not own this plant !!!"); } } else { from.SendLocalizedMessage(500446); } }
public override Item GetCropObject() { Cabbage cabbage = new Cabbage(); cabbage.ItemID = Utility.Random( 3195, 2 ); return cabbage; }
public void SameObjectsTest() { Potato potato = new Potato(200, 45, "Greenhouse type"); Cabbage cabbage = new Cabbage(100, 24, "1 year"); Assert.AreNotSame(potato, cabbage); Console.WriteLine("Objects are not the same."); }
public override Item GetCropObject() { Cabbage cabbage = new Cabbage(); cabbage.ItemID = Utility.Random(3195, 2); return(cabbage); }
public MainWindow() { InitializeComponent(); ModelView myModelView = new ModelView(); Cabbage myCabbage = new Cabbage(); myCabbage.Leaves = 99; myModelView.updateCabbageLeaves(myCabbage); }
public void ExceptionTest() { var salad = new Salad(); Vegetable cabbage = new Cabbage(100, 24, "1 year"); salad.Add(cabbage); Assert.Throws(typeof(Exception), () => salad.Add(cabbage)); }
public void TestToCheckTheQuantityOfTomatoes() { Refrigerator refrigerator = new Refrigerator(); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); refrigerator.AddVegetable(tomato, 10); refrigerator.AddVegetable(cabbage, 10); Assert.Equal(10, refrigerator.GetVegetableQuantity(tomato)); }
public void TestWhenQuantityIsSufficient() { Refrigerator refrigerator = new Refrigerator(); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); refrigerator.AddVegetable(tomato, 10); refrigerator.AddVegetable(cabbage, 8); string message = refrigerator.TakeOutVegetable(tomato, 2); Assert.Equal(8, refrigerator.GetVegetableQuantity(tomato)); }
/// <summary> /// Загрузка объектов этой игры по умолчанию. /// </summary> public void LoadDefaultGameObjects() { Cabbage cabbage = new Cabbage(); Goat goat = new Goat(); goat.WriteGameObjectThatCanEat(cabbage); Wolf wolf = new Wolf(); wolf.WriteGameObjectThatCanEat(goat); _gameObjects = new GameObject[] { cabbage, goat, wolf }; }
public void TestWhenQuantityReachesMinimumLimitAndOrderAutomaticallyPlaced() { Refrigerator refrigerator = new Refrigerator(); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); refrigerator.AddVegetable(tomato, 10); refrigerator.AddVegetable(cabbage, 8); string message = refrigerator.TakeOutVegetable(tomato, 10); Assert.Equal(5, refrigerator.GetVegetableQuantity(tomato)); }
public void VegetableTrayTakeOutExceptionTest() { VegetableTray vegetableTray = new VegetableTray(); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); LadyFinger ladyFinger = new LadyFinger(); vegetableTray.Add(tomato, 25); var actualVegetableQuantity = vegetableTray.GetVegetableQuantity(); Assert.Throws <VegetableNotFoundException>(() => vegetableTray.TakeOut(cabbage, 20)); }
public void TestWhenQuantityReachesMinimumLimitAndOrderPlacedNotifyUser() { Refrigerator refrigerator = new Refrigerator(); NotificationFactory notificationFactory = new NotificationFactory(); INotificationManager notificationManager = notificationFactory.GetNotificationType("email"); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); refrigerator.AddVegetable(tomato, 10); refrigerator.AddVegetable(cabbage, 8); Assert.Equal(notificationManager.NotifyMinimumValueReached() + "." + notificationManager.NotifyOrderPlacedStatus(), refrigerator.TakeOutVegetable(tomato, 10)); }
public void TestWhenQuantityIsSufficientNotifyUser() { Refrigerator refrigerator = new Refrigerator(); NotificationFactory notificationFactory = new NotificationFactory(); INotificationManager notificationManager = notificationFactory.GetNotificationType("email"); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); refrigerator.AddVegetable(tomato, 10); refrigerator.AddVegetable(cabbage, 8); Assert.Equal(notificationManager.NotifySufficientQuantity(), refrigerator.TakeOutVegetable(tomato, 8)); }
public override bool LootItem(Mobile from) { if (Utility.RandomDouble() <= .05) { CabbageSeed item = new CabbageSeed(); from.AddToBackpack(item); from.SendMessage("You manage to gather 1 cabbage seed."); } Cabbage c = new Cabbage(); c.ItemID = 3195; from.AddToBackpack(c); from.SendMessage("You manage to gather 1 cabbage."); return(true); }
public void TestVegetableQuantity() { Refrigerator refrigerator = new Refrigerator(); Cabbage cabbage = new Cabbage(); Tomato tomato = new Tomato(); refrigerator.AddVegetable(cabbage, 10); refrigerator.AddVegetable(tomato, 20); var expectedVegetableQuantity = new List <KeyValuePair <Vegetable, int> >(); expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(cabbage, 10)); expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(tomato, 20)); var actualVegetableQuantity = refrigerator.GetVegetableQuantity(); Assert.Equal(expectedVegetableQuantity.OrderBy(x => x.Key.Name).ToList(), actualVegetableQuantity.OrderBy(x => x.Key.Name).ToList()); }
public void VegetableTrayTakeOutPositiveTest() { VegetableTray vegetableTray = new VegetableTray(); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); LadyFinger ladyFinger = new LadyFinger(); vegetableTray.Add(tomato, 25); vegetableTray.TakeOut(tomato, 20); var actualVegetableQuantity = vegetableTray.GetVegetableQuantity(); var expectedVegetableQuantity = new List <KeyValuePair <Vegetable, int> >(); expectedVegetableQuantity.Add(new KeyValuePair <Vegetable, int>(tomato, 5)); Assert.Equal(expectedVegetableQuantity, actualVegetableQuantity); }
public override ILarge GetLarge(LargeType largeType) { switch (largeType) { case LargeType.Cabbage: ILarge cabbage = new Cabbage(); return(cabbage); case LargeType.Pineapple: ILarge pineapple = new Pineapple(); return(pineapple); case LargeType.Pumpkin: ILarge pumpkin = new Pumpkin(); return(pumpkin); } return(null); }
public void GetInsufficientVegetableQuantityTest() { var inMemoryStorage = new InMemoryStorage(); var config = new ConfigurationManager(inMemoryStorage); var vegetableTray = new VegetableTray(); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); config.SetMinimumQuantity(tomato, 3); config.SetMinimumQuantity(cabbage, 1); vegetableTray.Add(tomato, 5); vegetableTray.Add(cabbage, 3); vegetableTray.TakeOut(tomato, 3); VegetableTracker vegetableTracker = new VegetableTracker(vegetableTray, config); Assert.AreEqual(1, vegetableTracker.GetInsufficientVegetableQuantity().Count); }
public void PlaceOrder() { Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); VegetableTray tray = new VegetableTray(); tray.Add(tomato, 5000); tray.Add(cabbage, 4000); IStorage storage = new InMemoryStorage(); ConfigurationManager configurationManager = new ConfigurationManager(storage); configurationManager.SetMinimumQuantity(tomato, 2000); configurationManager.SetMinimumQuantity(cabbage, 2000); tray.TakeOut(tomato, 4000); VegetableTracker vegetableTracker = new VegetableTracker(configurationManager, tray); var insufficientVegetables = vegetableTracker.GetInsufficientVegetableQuantity(); Order order = new Order(vegetableTracker, configurationManager, tray); order.PlaceOrder(); List <KeyValuePair <Vegetable, int> > cartItems = new List <KeyValuePair <Vegetable, int> >() { new KeyValuePair <Vegetable, int>(new Tomato(), 2000), new KeyValuePair <Vegetable, int>(new Cabbage(), 4000) }; var trayVegetables = tray.GetVegetableQuantity(); for (int i = 0; i < cartItems.Count; i++) { Assert.Equal(cartItems[i].Value, trayVegetables[i].Value); } }
static void Main(string[] args) { // Create vegatables and attach restorants Cucumber cucumber = new Cucumber("Краставици", 02.10); cucumber.Attach(new Restorant("Одеон")); cucumber.Attach(new Restorant("Никол")); cucumber.Attach(new Restorant("Виктория")); Cabbage cabbage = new Cabbage("Зеле", 01.05); cabbage.Attach(new Restorant("Одеон")); cabbage.Attach(new Restorant("Никол")); cabbage.Attach(new Restorant("Виктория")); Tomato tomato = new Tomato("Домат", 01.95); tomato.Attach(new Restorant("Одеон")); tomato.Attach(new Restorant("Никол")); tomato.Attach(new Restorant("Виктория")); // Fluctuating prices will notify restorants cucumber.Price = 02.25; cucumber.Price = 02.15; cucumber.Price = 02.20; cabbage.Price = 01.10; cabbage.Price = 01.15; cabbage.Price = 01.10; tomato.Price = 02.10; tomato.Price = 02.25; tomato.Price = 02.20; // Wait for user Console.ReadKey(); }
public void PlaceOrderOfInsufficientVegetablesTest() { var vegetableTray = new VegetableTray(); var inMemoryStorage = new InMemoryStorage(); var configurationManager = new ConfigurationManager(inMemoryStorage); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); configurationManager.SetMinimumQuantity(tomato, 3); configurationManager.SetMinimumQuantity(cabbage, 1); vegetableTray.Add(tomato, 1); vegetableTray.Add(cabbage, 3); var placeOrder = new PlaceOrder(vegetableTray, configurationManager); var placedOrderList = new Dictionary <Vegetable, int>(); placedOrderList.Add(tomato, 2); Assert.AreEqual(placedOrderList.Count, placeOrder.PlaceOrderOfInsufficientVegetables().Count); }
public IFood CreateFood(int money) { IFood aCucumber = new Cucumber(); IFood aCarrot = new Carrot(); IFood aCabbage = new Cabbage(); if (money >= aCucumber.CostPerKg) { return(aCucumber); } else if (money >= aCarrot.CostPerKg) { return(aCarrot); } else if (money >= aCabbage.CostPerKg) { return(aCabbage); } else { return(null); } }
public void InsufficientQauntity() { Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); VegetableTray tray = new VegetableTray(); tray.Add(tomato, 5000); tray.Add(cabbage, 4000); tray.TakeOut(tomato, 4000); IStorage storage = new InMemoryStorage(); ConfigurationManager configurationManager = new ConfigurationManager(storage); configurationManager.SetMinimumQuantity(tomato, 2000); configurationManager.SetMinimumQuantity(cabbage, 2000); VegetableTracker vegetableTracker = new VegetableTracker(configurationManager, tray); var insufficientVegetables = vegetableTracker.GetInsufficientVegetableQuantity(); Assert.Equal(tomato.Name, insufficientVegetables[0].Key.Name); }
public void TakeOutVegetableFromTray() { var tray = new VegetableTray(); Tomato tomato = new Tomato(); Cabbage cabbage = new Cabbage(); tray.Add(tomato, 8000); tray.Add(cabbage, 5000); tray.TakeOut(tomato, 2000); tray.TakeOut(cabbage, 2000); var trayVegetables = tray.GetVegetableQuantity(); List <KeyValuePair <Vegetable, int> > cartItems = new List <KeyValuePair <Vegetable, int> >() { new KeyValuePair <Vegetable, int>(new Tomato(), 6000), new KeyValuePair <Vegetable, int>(new Cabbage(), 3000) }; for (int i = 0; i < cartItems.Count; i++) { Assert.Equal(cartItems[i].Value, trayVegetables[i].Value); } }
private void btn_Cabbage_Click(object sender, RoutedEventArgs e) { Cabbage cabbage = new Cabbage(); cabbage.Show(); }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage("You cannot harvest a crop while mounted."); return; } if (DateTime.Now > lastpicked.AddSeconds(1)) // 3 seconds between picking changed to 1 sec { lastpicked = DateTime.Now; int cookingValue = (int)from.Skills[SkillName.Cooking].Value / 20; if (cookingValue == 0) { from.SendMessage("You have no idea how to harvest this crop."); return; } if (from.InRange(this.GetWorldLocation(), 1)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); if (PlayerCanDestroy && !(m_sower.AccessLevel > AccessLevel.Counselor)) { UpRootGump g = new UpRootGump(from, this); from.SendGump(g); } } else //check skill and sower { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0); if (from == m_sower) { cookingValue *= 2; m_lastvisit = DateTime.Now; } if (cookingValue > m_yield) { cookingValue = m_yield + 1; } int pick = Utility.Random(cookingValue); if (pick == 0) { from.SendMessage("You do not manage to harvest any crops."); return; } m_yield -= pick; from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s")); //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); ((Item)this).ItemID = pickedGraphic; Cabbage crop = new Cabbage(pick); from.AddToBackpack(crop); if (SowerPickTime != TimeSpan.Zero && m_lastvisit + SowerPickTime < DateTime.Now && !(m_sower.AccessLevel > AccessLevel.Counselor)) { this.UpRoot(from); return; } if (!regrowTimer.Running) { //regrowTimer = new CropTimer( this ); regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to harvest anything."); } } }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage(AgriTxt.CannotWorkMounted); return; } if (DateTime.Now > lastpicked.AddSeconds(3)) // 3 seconds between picking { lastpicked = DateTime.Now; int lumberValue = (int)from.Skills[SkillName.Lumberjacking].Value / 5; if (lumberValue == 0) { from.SendMessage(AgriTxt.DunnoHowTo); return; } if (from.InRange(this.GetWorldLocation(), 2)) { if (m_yield < 1) { from.SendMessage(AgriTxt.NoCrop); if (PlayerCanDestroy && !(m_sower.AccessLevel > AccessLevel.Counselor)) { UpRootGump g = new UpRootGump(from, this); from.SendGump(g); } } else //check skill and sower { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29 : 32, 5, 1, true, false, 0); if (from == m_sower) { lumberValue *= 2; m_lastvisit = DateTime.Now; } if (lumberValue > m_yield) { lumberValue = m_yield + 1; } int pick = Utility.Random(lumberValue); if (pick == 0) { from.SendMessage(AgriTxt.ZeroPicked); return; } m_yield -= pick; from.SendMessage(AgriTxt.YouPick + " {0} chou{1}!", pick, (pick == 1 ? "" : "x")); //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); ((Item)this).ItemID = pickedGraphic; Cabbage crop = new Cabbage(pick); from.AddToBackpack(crop); if (SowerPickTime != TimeSpan.Zero && m_lastvisit + SowerPickTime < DateTime.Now && !(m_sower.AccessLevel > AccessLevel.Counselor)) { this.UpRoot(from); return; } if (!regrowTimer.Running) { //regrowTimer = new CropTimer( this ); regrowTimer.Start(); } } } else { from.SendMessage(AgriTxt.TooFar); } } }