static void Main(string[] args) { Shop Evroopt = new Shop("Евроопт"); Evroopt.Add(new Item("Кока-кола 2л", 3.09f)); Evroopt.Add(new Item("Спрайт 1л", 1.79f)); Evroopt.Add(new Item("Фанта 0.5л", 1.19f)); Console.WriteLine("Магазин: " + Evroopt); foreach (var item in Evroopt) { Console.WriteLine(item.Name + ":\t" + item.Price + " BYN"); } var Enumerator = Evroopt.GetEnumerator(); Enumerator.MoveNext(); Manager.Sale += new Manager.SaleHandler(Enumerator.Current.OnSale); Enumerator.MoveNext(); Manager.Sale += new Manager.SaleHandler(Enumerator.Current.OnSale); Console.WriteLine("---------------РАСПРОДАЖА---------------"); Manager.CommandSale(); Console.WriteLine("Магазин: " + Evroopt); foreach (var item in Evroopt) { Console.WriteLine(item.Name + ":\t" + item.Price + " BYN"); } Console.WriteLine("-----------------------------------------"); Console.WriteLine("Linq запрос: " + Evroopt.Where(x => x.Name == "Фанта 0.5л").Select(x => x.Price).First()); }
static void Main(string[] args) { Shop shop = new Shop(new ShopItemGroup(new List <IShopItem>()), new List <IUser>(), new List <IManager>(), new List <IOrder>() ); shop.Add( new InetShopLibrary.Users.User( id: 1, fullName: "Вася Козлов", address: new Address() )); shop.Add( new InetShopLibrary.Users.Manager(id: 1, fullName: "Петя Ослов")); }
public void StorageAndItem_BenzeneAddToInventory_ItemAmountIncrease() { IContainer ShopTest = new Shop(); IChemical Benzene = new Butane(); ShopTest.Add(Benzene); Assert.IsTrue(ShopTest.ItemAmount == 1); }
public void StorageAndItem_CargoPantsAddToShop_ItemAmountIncrease() { IContainer ShopTest = new Shop(); IContainer CargoPants = new CargoPants(); ShopTest.Add((IItem)CargoPants); Assert.IsTrue(ShopTest.ItemAmount == 1); }
public void StorageAndItem_SmallJarAddToShop_ItemAmountIncrease() { IContainer ShopTest = new Shop(); IItem MasonJar = new SmallMasonJar(); ShopTest.Add(MasonJar); Assert.IsTrue(ShopTest.ItemAmount == 1); }
public ActionResult Create([Bind(Include = "ArticleNumber,Name,Price,ShelfPosition,Quantity,Description")] ShopItem shopItem) { //This shares a lot with the edit view, so the views should have a partial view for the item details as well if (ModelState.IsValid) { shop.Add(shopItem); return(RedirectToAction("Index")); } return(View(shopItem)); }
public async Task <IActionResult> Create([Bind("ID,MagazinName,Adress")] Magazin magazin) { if (ModelState.IsValid) { _context.Add(magazin); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(magazin)); }
public async Task <IActionResult> Create([Bind("ID,CategoryName,Description")] Category category) { if (ModelState.IsValid) { _context.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
static void Main(string[] args) { User me = new User("Hovo", 200); Bus b = new Bus(20, 50, 10, "Hundai", 50, 0.01); Truck t = new Truck(50, 50, 10, "Furz", 50, 0.01); Sedan s = new Sedan(50, 50, 10, "Ferrari", 50, 0.01); Shop sh = new Shop(20); sh.Add(b, 50); sh.Add(t, 60); sh.Add(s, 100); sh.Add(b, 50); sh.Add(t, 60); sh.Add(s, 100); sh.Add(b, 50); sh.Add(t, 60); sh.Add(s, 100); while (true) { Console.Clear(); Console.WriteLine("Where do you want to go ? \n Shop ? Garage ? Exit ?"); string ans = Console.ReadLine(); Console.Clear(); if (ans.ToUpper() == "SHOP") { sh.Trade(me); } else if (ans.ToUpper() == "GARAGE") { me.DisplayCars(); Console.ReadKey(); } else if (ans.ToUpper() == "EXIT") { break; } } }
public void ShopRefresh() { // use a for loop to decide which should be in shop for (int i = 0; i < AllItems.Length; i++) { if (itemStatus[i] == 0) { if (!shop.shopItems.Contains(AllItems[i])) // since index are all the same throughout item's itemIndex, AllItems index, AllItemsObjectsIndex { shop.Add(AllItems[i]); //Debug.Log("ADDED TO SHOPPO"); //Debug.Log(AllItems.Length); } } } }
public async Task <IActionResult> Create([Bind("Title,Brand,Price,Weight")] Product product) { try { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex*/) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists "); } return(View(product)); }
public async Task <IActionResult> Create([Bind("Denumire,Categorie,Pret")] Costum costum) { try { if (ModelState.IsValid) { _context.Add(costum); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex*/) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists "); } return(View(costum)); }
//Magazinul cu pantofi //Descriere: Într-un magazin care vinde pantofi există un singur raft pe care sunt puse toate cutiile de //pantofi, una după alta, în ordine crescătoare a numărului de pe pantofi(de ex. 36, 37, 42, etc.). Fiecare //pantof are o mărime, o culoare și un preț. //Ne trebuie un container pentru: a reține pantofii de pe raft //Funcționalități: // 1. Adăugați pantofi noi la raft(când vânzătorul aduce pantofi noi) // 2. Verificați dacă oferta de pantofi este echilibrată(oferta de pantofi se consideră echilibrată dacă // diferența maximă dintre stocurile pentru fiecare mărime existentă este 3. // 3. O clientă mai specială, Marisol, are o metodă interesantă de a cumpăra pantofi. Alege în mod // aleator 2 poziții de pe raft, și cere să-i fie aduse toate perechile de pantofi dintre cele 2 poziții // (aceste elemente sunt eliminate de pe raft). Clienta parcurge șirul de pantofi și dintre acele // perechi care corespund cu mărimea ei, alege fiecare a 2-a pereche de pantofi.Restul pantofilor // sunt puși înapoi pe raft. Afișați lista pantofilor cumpărați de clienta, lista pantofilor rămași pe // raft după plecarea ei și prețul plătit de ea. //Exemple: // Să presupunem că la un moment dat avem următoarele pantofi: //o(34, negru, 25) //o(34, verde, 50) //o(34, gri, 32) //o(35, negru, 35) //o(35, negru, 10) //o(35, rosu, 71) //o(36, gri, 13) //o(36, verde, 43) //o(36, negru, 39) //o(36, negru, 32) //o(37, negru, 15) //o(37, verde, 43) //o(38, negru, 33) //o(38, negru, 27) // Oferta de pantofi este echilibrată: avem 3 pantofi 34, 3 pantofi 35, 4 pantofi 36, 2 pantofi 37, 2 //pantofi 38. Diferența maximă 4-2 = 2. // Dacă Marisol poartă 36 și alege pozițiile 6, 12, ea va primi pantofii: //o(36, gri, 13) //o(36, verde, 43) //o(36, negru, 39) //o(36, negru, 32) //o(37, negru, 15) //o(37, verde, 43) //o(38, negru, 33) // Din care va alege(36, gri, 13) și(36, negru, 39) și va plăti 52 sau va alege(36, verde, 43) și(36, //negru, 32) și va plăti 75 (oricare variantă e corectă). static void Main(string[] args) { int option = Menu.Options(); Shop shelf = null; while (option != 0) { switch (option) { case 1: // Instantiate and print the shop's shelf with the shoes added from the database. shelf = new Shop(Database.InitializeDatabase()); shelf.PrintDatabase(); break; case 2: // Add a new pair of shoes on the shelf and print the shelf updated. var newShoe = new Shoe(34, "red", 63); shelf.Add(newShoe); shelf.PrintShelfUpdatedWithNewShoe(); break; case 3: // Verify if the shop has the offer balanced or not. Console.WriteLine($"The offer is balanced: {shelf.IsBalancedTheOffer()}"); break; case 4: // Print the list of shoes bought by a client and the price paid. // Print the list of shoes that will remain on the shelf after the client bought some of them. shelf.Client(); break; default: Console.WriteLine("Please enter a valid option!"); option = Menu.Options(); break; } option = Menu.Options(); } }
public void Sell_NewBook_CheckCreatedInMemory() { // Arrange var bookData = new BookMemoryData(); var checkData = new CheckMemoryData(); var shop = new Shop(bookData, checkData); var book = new Book { Author = "TestAuthor", Name = "TestName", Price = 100 }; // Act shop.Add(book); var books = shop.GetAllBooks().ToList(); var check = shop.Sell(book); // Assert Assert.IsNotNull(books); Assert.IsNotNull(check); }
protected void AddCategories() { ICategory root = new Category(new List <ICategory>()) { Id = 0, Name = "All" }; _shop.Add(root, null); _shop.Add(new Category(new List <ICategory>()) { Id = 1, Name = "Вилы" }, root); _shop.Add(new Category(new List <ICategory>()) { Id = 2, Name = "Грабли" }, root); _shop.Add(new Category(new List <ICategory>()) { Id = 3, Name = "Фуфайки" }, root); }
public static void DoShopping(int x, int y, Shop shop, BuyItem buyMethod, SellItem sellMethod) { #region Draw list of items ActionPanel.ClearArea(); var exitFlag = false; var current = 0; if (shop.DescriptionItems != null) foreach (var item in shop.DescriptionItems) { var caption = item.Split('\t')[0]; var text = item.Split('\t')[1]; shop.Add(new ShopItem(caption, 0, true, text, true)); } if (shop.HasQuit) { shop.Add(new ShopItem(ActionPanel.Common_Quit, 0, true, null, true)); } while (!shop[current].IsActive) current++; var oldPosition = current; var goodsX = x + 3; var goodsY = y + 2; var lastIndex = shop.Count - 1; var isBBC = shop.Type == ShopType.BBC; ZFrame.DrawFrame(x, y, new ZFrame.Options{ Caption = shop.Name, Width = shop.Header.Length+6, Height = lastIndex+4, FrameType = FrameType.Double}); ZOutput.Print(goodsX, y+1, shop.Header, Color.Cyan, Color.Black); for (var i = 0; i < shop.Count; i++) PrintItem(goodsX, goodsY + i, shop, shop[i], isBBC); ZOutput.Print(x + (shop.Header.Length+6-shop.Footer.Length)/2, goodsY+shop.Count+1, shop.Footer, Color.Red, Color.Black); #endregion while (!exitFlag) { var item = shop[current]; PrintItem(goodsX, goodsY + current, shop, item, isBBC, true); var key = ZInput.ReadKey(); switch (key) { case ConsoleKey.UpArrow : do { current = (current > 0) ? current - 1 : lastIndex; } while (!shop[current].IsActive); break; case ConsoleKey.DownArrow: do { current = (current < lastIndex) ? current + 1 : 0; } while (!shop[current].IsActive); break; case ConsoleKey.Enter : case ConsoleKey.PageUp : case ConsoleKey.RightArrow: case ConsoleKey.Add: case ConsoleKey.Insert: #region Buy Item if (item.Name == ActionPanel.Common_Quit) { exitFlag = true; break; } if (item.ItemObject is string) { EventLog.Print(item.ItemObject as string); break; } if (shop.Type != ShopType.BBC) { if (Player.Credits >= item.Price) { exitFlag = buyMethod(item) ? shop.ExitAfter : exitFlag; } else { EventLog.Print("Planet_NoMoneyToBuy"); } } else { buyMethod(item); } PlayerStats.Draw_PlayerStats(); break; #endregion case ConsoleKey.PageDown: case ConsoleKey.LeftArrow: case ConsoleKey.Subtract: case ConsoleKey.Delete: #region Sell Item if (item.Name == ActionPanel.Common_Quit) { exitFlag = true; break; } if (item.ItemObject is string) { EventLog.Print(item.ItemObject as string); break; } var result = (sellMethod != null) ? sellMethod(item) : buyMethod(item); exitFlag = result && shop.ExitAfter; PlayerStats.Draw_PlayerStats(); break; #endregion case ConsoleKey.Escape: case ConsoleKey.Backspace: exitFlag = true; break; case ConsoleKey.F1 : HelpInfo.Show(); break; case ConsoleKey.F5 : PlayerInfo.Show(); break; case ConsoleKey.F6 : GalaxyInfo.Show(); break; case ConsoleKey.F10 : ZFrontier.Quit_Game(); break; } while (!shop[current].IsActive) current = (current < lastIndex) ? current + 1 : 0; if (current != oldPosition) { PrintItem(goodsX, goodsY + oldPosition, shop, shop[oldPosition], isBBC); oldPosition = current; } } ActionPanel.ClearArea(); }