public override void AddMany(int amount) { for (var i = 0; i < amount; i++) { Stock.Add(new HeatRegulatorPart(SetRandomDurability())); } }
public void RemoveWhenProductExistAndThereIsNotEnoughProductsShouldReturnFalse() { Product testProduct = new Product("apricot", 16); bool notificationSent = false; Action <Product> notification = product => { // Notification will not be sent at any given moment notificationSent = true; }; ProcessProduct testNotification = new ProcessProduct(notification); Stock stockTest = new Stock(testNotification); stockTest.Add(testProduct); Product productToRemove = new Product("apricot", 20); Assert.False(stockTest.Remove(productToRemove)); Assert.Equal(16, stockTest.Check(new Product("apricot", 0))); Assert.False(notificationSent); }
public void RemoveWhenProductExistAndThereIsAtLeast10ProductsLeftShouldReturnTrueAndRemoveQuantity() { bool notificationSent = false; Action <Product> notification = product => { // Notification will not be sent at any given moment notificationSent = true; }; ProcessProduct testNotification = new ProcessProduct(notification); Stock stockTest = new Stock(testNotification); Product testProduct = new Product("apricot", 16); stockTest.Add(testProduct); Product productToRemove = new Product("apricot", 6); Assert.True(stockTest.Remove(productToRemove)); Assert.Equal(10, stockTest.Check(testProduct)); Assert.False(notificationSent); }
public StockBeheerder() { Stock.Add(Bestelling.ProductType.Dubbel, 100); Stock.Add(Bestelling.ProductType.Trippel, 100); Stock.Add(Bestelling.ProductType.Kriek, 100); Stock.Add(Bestelling.ProductType.Pils, 100); }
public override void AddMany(int amount) { for (var i = 0; i < amount; i++) { Stock.Add(new SportSuspensionMod(SetRandomDurability())); } }
public override void AddMany(int amount) { for (var i = 0; i < amount; i++) { Stock.Add(new ExhaustPipeMod(SetRandomDurability())); } }
//simply load the stock with all of the ingredients in the enum (set to 0) void LoadAllStockItems() { foreach (string ingredient in Enum.GetNames(typeof(IngredientsEnum))) { Stock.Add((IngredientsEnum)Enum.Parse(typeof(IngredientsEnum), ingredient), 0); } }
public override void AddMany(int amount) { for (var i = 0; i < amount; i++) { Stock.Add(new TitaniumWipersMod(SetRandomDurability())); } }
private void Given_product_is_in_stock() { var product = "product"; _stock.Add(product); StepExecution.Current.Comment(string.Format("Added '{0}' to the stock", product)); }
public override void AddMany(int amount) { for (var i = 0; i < amount; i++) { Stock.Add(new CustomBonnetMod(SetRandomDurability())); } }
private async Task SaveStock() { List <Task <bool> > tasks = new List <Task <bool> >(); if (PartIds.Any()) { foreach (StockTaking Stock in Stocks) { tasks.Add(Task.Run(() => Stock.Add())); } var res = await Task.WhenAll <bool>(tasks); if (res.Any(i => i == false)) { int number = res.Count(i => i == false); string msgText = "Serwer zwrócił błąd, inwentaryzacja nie została zapisana.."; if (number > 1) { msgText = $"Próba zaktualizowania zapasu zakończyła się niepowodzeniem w przypadku {number} części.."; } MessageBox.Show(msgText, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show($"Inwentaryzacja została zapisana i zapas zaktualizowany", "Powodzenie", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
static void GenereStockLivre() { var random = new Random(); // on fabrique 100 livres au max for (int i = 0; i < random.Next(20, 100); i++) { Random.Person p = random.NextPerson(Random.AllowedLanguage.FRENCH); string titre = random.NextLoremIpsum(random.Next(2)); var livre = new Livre(titre, p.FirstName, p.LastName) { PrixUnitaireHt = random.Next(1, 200) + random.NextDouble(), Quantite = random.Next(20) }; stock.Add(livre); } }
public void addProductsToStock(List <IProduct> products) { if (Stock.ContainsKey(products.First().GetType())) { Stock[products.First().GetType()].AddRange(products); } // Add the new product to the stock Stock.Add(products.First().GetType(), products); }
private void DoBuyAnimal(Animal animal, int cost) { var newStock = new PetShopAnimalViewModel(); newStock.Animal = animal; newStock.Price = _pricingModel.CalculateInitialSalesPrice(cost); newStock.SellCommand = new MvxCommand(() => DoSale(newStock)); BankBalance = BankBalance - cost; Stock.Add(newStock); }
public void addProduct(IProduct product) { if (Stock.ContainsKey(product.GetType())) { Stock[product.GetType()].Add(product); } // Add the new product to the stock List <IProduct> products = new List <IProduct>() { product }; Stock.Add(product.GetType(), products); }
public void AddWhenProductExistShouldIncreaseQuantity() { bool notificationSent = false; Action <Product> notification = product => { // Notification will not be sent at any given moment notificationSent = true; }; ProcessProduct testNotification = new ProcessProduct(notification); Stock stockTest = new Stock(testNotification); Product testProduct = new Product("apricot", 8); stockTest.Add(testProduct); stockTest.Add(testProduct); Assert.Equal(16, stockTest.Check(testProduct)); Assert.False(notificationSent); }
//draw a card from stock or discard //player //pile public void DrawCard(Player player, PileName pn) { if (!CanDraw(player)) { _currentError = ErrorMessage.NotPlayerTurn; throw new ArgumentException("It is not this player's turn", "player"); } if (IsPileEmpty(pn)) { throw new ArgumentException("The pile is empty", "pn"); } Card c = PopFromPile(pn); AddToPlayerCards(player, c); //if drawn from discard pile, remeber the card if (pn == PileName.Discard) { _cardJustDrawn = c; } else { _cardJustDrawn = null; } if (pn == PileName.Stock && IsPileEmpty(PileName.Stock)) { var topOnDiscard = Discard.Pop(); while (Discard.Count > 0) { Stock.Add(Discard.Pop()); Stock.Shuffle(null); } Discard.Add(topOnDiscard); } _currentError = ErrorMessage.NoError; var newState = (player == Player.One) ?State.Player1MeldLayDiscard : State.Player2MeldLayDiscard; AfterActStuff(new DrawMove(player, pn), newState); }
/// <summary> /// Add some number of items to the store's stock /// </summary> /// <param name="product">Product object thats stock is to be modified</param> /// <param name="qty">Integer value by how much to modify the stock</param> /// <returns>True if succeeded in modifying the stock amount. False if there was an attempt to input a negative amount for a non-yet-stocked product</returns> public bool AddStock(Product product, int qty) { if (Stock.ContainsKey(product)) { if (qty < 0 && System.Math.Abs(qty) > Stock[product]) { return(false); } Stock[product] += qty; return(true); } else if (qty > 0) { Stock.Add(product, qty); return(true); } return(false); }
static void GenereStockPapeterie(Stock <IProduit> stock) { var random = new Random(); // on fabrique 100 produits au max for (int i = 0; i < random.Next(100); i++) { string designation = random.NextWord(10); var categorie = (Papeterie.CategorieEnum)random.Next(Enum.GetValues(typeof(Papeterie.CategorieEnum)).Length - 1); var papeterie = new Papeterie(categorie, designation) { PrixUnitaireHt = random.Next(1, 200) + random.NextDouble(), Quantite = random.Next(20) }; stock.Add(papeterie); } }
private void Add_Clicked(object sender, EventArgs e) { try { if (!CrashCheck()) { var Geselecteerd = (PickerItems)PickerStock.SelectedItem; Console.WriteLine(Geselecteerd.Name + "Geselecteerd name"); Stock stock = new Stock(); stock.Add(Geselecteerd.Name, Convert.ToInt32(EntryAmount.Text)); string AlertString = Geselecteerd.Name + " is " + EntryAmount.Text + " keer toegevoegd aan de boodschappenlijst!"; DisplayAlert("Success", AlertString, "Terug"); } } catch (Exception ex) { Console.WriteLine("error op gevange in NewStockPage " + ex); DisplayAlert("Oops", "Er is iets fout gegaan, probeer het nog eens.", "Terug"); } }
public void AddWhenNullProductShouldThrowException() { bool notificationSent = false; Action <Product> notification = product => { // Notification will not be sent at any given moment notificationSent = true; }; ProcessProduct testNotification = new ProcessProduct(notification); Stock stockTest = new Stock(testNotification); Product testProduct = null; Assert.Throws <ArgumentNullException>(() => stockTest.Add(testProduct)); Assert.False(notificationSent); }
static void Main(string[] args) { Product product = new Product("wire", 22.44m, "2020,08,30"); Console.WriteLine($"Name: {product.Name}\nPrice: {product.Price}\nDelivery Date: {product.DeliveryDate}"); Console.WriteLine(); Product product2 = new Product("sand", 33.55m, "2020,08,23"); Console.WriteLine($"Name: {product2.Name}\nPrice: {product2.Price}\nDelivery Date: {product2.DeliveryDate}"); Console.WriteLine(); Product product3 = new Product("iron", 120, "2020,08,25"); Console.WriteLine($"Name: {product3.Name}\nPrice: {product3.Price}\nDelivery Date: {product3.DeliveryDate}"); Stock.Add(product); Stock.Add(product2); Stock.Add(product3); Console.WriteLine(); string expirationDate = product.ExpirationDateEmulator("2020,08,29"); Console.WriteLine($"The expiration date of the {product.Name} is {expirationDate}"); expirationDate = product2.ExpirationDateEmulator("2020,01,29"); Console.WriteLine($"The expiration date of the {product2.Name} is {expirationDate}"); expirationDate = product3.ExpirationDateEmulator("2019/02/22"); Console.WriteLine($"The expiration date of the {product3.Name} is {expirationDate}"); foreach (var item in Stock.GetProdcuts()) { Console.WriteLine($"\n{item}"); } Console.ReadKey(); }
public static void SelectBaseQtyProducts(List <Product> products, Stock stock) { Store.products = products; while (true) { Console.Clear(); Console.WriteLine("Insert product and start qty:"); for (int i = 0; i < products.Count; i++) { Console.WriteLine($"{i + 1} { products[i].Name }"); } //var ProductID = 1; Console.Write("Insert product: "); var ProductID = 0; var inputID = Console.ReadLine(); int.TryParse(inputID, out ProductID); if (ProductID == 0) { break; } //var qty = 50; Console.Write("Insert qty: "); var qty = 0; var inputQty = Console.ReadLine(); int.TryParse(inputQty, out qty); if (qty == 0) { break; } products[ProductID - 1].SetBaseQty(qty); stock.Add(products[ProductID - 1], qty, new DateTime(2019, 06, 23)); products.Remove(products[ProductID - 1]); } }
public void RemoveWhenThereIsBeetwen1and0ProductsLeftShouldSendNotificationOnce() { Product testProduct = new Product("apricot", 2); string notifiedProduct = null; int notifiedQuantity = -1; int numberOfNotifications = 0; Action <Product> notification = product => { notifiedProduct = product.Name; notifiedQuantity = product.Quantity; numberOfNotifications++; }; ProcessProduct testNotification = new ProcessProduct(notification); Stock stockTest = new Stock(testNotification); stockTest.Add(testProduct); Product productToRemove = new Product("apricot", 1); Assert.True(stockTest.Remove(productToRemove)); Assert.Equal(1, stockTest.Check(testProduct)); Assert.Equal(testProduct.Name, notifiedProduct); Assert.Equal(1, notifiedQuantity); Assert.Equal(1, numberOfNotifications); // Second Remove, no notification sent Assert.True(stockTest.Remove(productToRemove)); Assert.Equal(0, stockTest.Check(testProduct)); Assert.Equal(testProduct.Name, notifiedProduct); Assert.Equal(1, notifiedQuantity); Assert.Equal(1, numberOfNotifications); }
/// <summary> /// Deals a new game. /// </summary> /// <param name="parameter">The parameter.</param> protected override void NewGameCommandExecute(object parameter) { // Call the base, which stops the timer, clears // the score etc. base.NewGameCommandExecute(parameter); // Clear everything. Stock.Clear(); Waste.Clear(); foreach (var tableau in _tableaus) { tableau.Clear(); } foreach (var foundation in _foundations) { foundation.Clear(); } // Create a list of card types. var eachCardType = Enum.GetValues(typeof(CardType)).Cast <CardType>().ToList(); // Create a playing card from each card type. var playingCards = eachCardType.Select(cardType => new PlayingCardViewModel { CardType = cardType, IsFaceDown = true }).ToList(); // Shuffle the playing cards. playingCards.Shuffle(); // Now distribute them - do the tableaus first. for (var i = 0; i < 7; i++) { // We have i face down cards and 1 face up card. for (var j = 0; j < i; j++) { var faceDownCard = playingCards.First(); playingCards.Remove(faceDownCard); faceDownCard.IsFaceDown = true; _tableaus[i].Add(faceDownCard); } // Add the face up card. var faceUpCard = playingCards.First(); playingCards.Remove(faceUpCard); faceUpCard.IsFaceDown = false; faceUpCard.IsPlayable = true; _tableaus[i].Add(faceUpCard); } // Finally we add every card that's left over to the stock. foreach (var playingCard in playingCards) { playingCard.IsFaceDown = true; playingCard.IsPlayable = false; Stock.Add(playingCard); } playingCards.Clear(); }
public double displayPrice() { DateTime date = new DateTime(2015, 03, 27); DateTime debutProduit = new DateTime(2014, 12, 18); DateTime finProduit = new DateTime(2022, 12, 08); Data.RecupData recup = new RecupData(new DateTime(2000, 1, 1), date); //Data.RecupData recup1 = new RecupData(new DateTime(2000, 1, 1), debutProduit); recup.Fetch(); //recup1.Fetch(); double t = recup.DateToDouble(debutProduit, date, finProduit); double[,] covLogR = recup.exportCov(new DateTime(2004, 01, 01), new DateTime(2014, 01, 01)); double[,] pastDelta = recup.exportPast(t, 7, debutProduit, finProduit); double[,] pastPrice = recup.exportPast(t, 182, debutProduit, finProduit); DateTime debutBackTest = new DateTime(2010, 03, 22); DateTime finBacktest = new DateTime(2018, 03, 22); double t0 = recup.DateToDouble(debutBackTest, finBacktest, finBacktest); double[,] donneesHistoriques = recup.exportPast(t0, 7, debutBackTest, finBacktest); //int size, double r, double* VarHis, double* spot, double* trend, double fdStep, int nbSamples, double strike, double T1, int nbTimeSteps1, double* lambdas1 double r_eu = 0.002; double r_aus = 0.025; double r_us = 0.00025; int size = 5; double r = r_eu; double[] spots = new double[5]; for (int i = 0; i < 5; i++) { spots[i] = pastPrice[0, i]; } double[] trends = new double[5]; trends[0] = r_eu; trends[1] = r_us - covLogR[1, 3]; trends[2] = r_aus - covLogR[2, 4]; trends[3] = r_eu - r_us; trends[4] = r_eu - r_aus; double[] lambdas = new double[5]; for (int i = 0; i < 5; i++) { lambdas[i] = 0.05; } WrapperClass wc = new WrapperClass(size, r, covLogR, spots, trends, 0.1, 500, 10, 8.0, 16, lambdas); double[] delta = new double[5]; double H = 416; int m = pastDelta.GetLength(0); double[] price = new double[m]; double[] pocket = new double[m]; double[] tracking = new double[m - 1]; wc.trackingError(pastDelta, pastPrice, t, H, price, pocket, tracking, m, pastPrice.GetLength(0)); Stock stock = new Stock(recup); stock.Add(0.0, wc.getDeltaEurostral(recup.exportPast(0, 182, debutProduit, finProduit), 0.0, H), price[0], 0.0); for (int i = 1; i < m - 1; i++) { stock.Add(i * 8.0 / H, wc.getDeltaEurostral(recup.exportPast(i * 8.0 / H, 182, debutProduit, finProduit), i * 8.0 / H, H), price[i], tracking[i - 1]); } stock.Add(t, wc.getDeltaEurostral(recup.exportPast(t, 182, debutProduit, finProduit), t, H), price[m - 1], tracking[m - 2]); stock.SaveToCSV(); return(wc.getPriceEurostral(t, pastPrice)); }
public void SellItem(Item item, Player player) { player.Gold += item.Cost; player.Inventory.Items.Remove(item); Stock.Add(item); }
private void Given_product_is_in_stock() { _stock.Add("product"); }
private void btnAdd_Click(object sender, EventArgs e) { //Thread t = new Thread(new ThreadStart(GifLoadingSaveSales)); try { if (txtSupName.SelectedValue == null) { MessageBox.Show("Invalid Supplier Name"); txtSupName.ResetText(); txtSupName.DataSource = null; txtSupName.DataSource = bank; txtSupName.ValueMember = "Id"; txtSupName.DisplayMember = "Company"; return; } if (txtSupName.Text == "SalesReturnStock") { MetroMessageBox.Show(this, "Selected suppilier name is system reserved keyword. You can't use this record, Please try another suppilier name or add a new name", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //MessageBox.Show(txtSupName.SelectedValue.ToString()); //MessageBox.Show(txtSupName.Text.ToString()); if (string.IsNullOrEmpty(txtSupName.Text) || string.IsNullOrEmpty(txtInvoiceNo.Text) || string.IsNullOrEmpty(txtStockID.Text) || string.IsNullOrEmpty(cmbDate.Text) || txtSupName.SelectedValue == null) { MetroMessageBox.Show(this, "Please enter valid data to the text fields", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bool resul = stock_product_list.Any(); if (!resul) { MessageBox.Show("No Product details were added to the stock"); return; } else { // t.Start(); using (TransactionScope txScope = new TransactionScope()) { DateTime d; d = Convert.ToDateTime(cmbDate.Text); int stockID = Convert.ToInt32(txtStockID.Text); string supName = txtSupName.Text; string invoiceNo = txtInvoiceNo.Text; Stock stock = new Stock(); stock.invoice_no = invoiceNo; stock.stock_id = stockID; stock.sup_name = supName; stock.s_date = d; stock.Sup_id = Convert.ToInt32(txtSupName.SelectedValue.ToString()); if (stock.Add(con)) { string query = @"select IDENT_CURRENT('_Stokc')"; int lastInsertedID = Convert.ToInt32(Sales_BM.getScalar(con, query)); stockID = lastInsertedID; int count = 0; foreach (var item in stock_product_list) { item.stock_id = lastInsertedID; item.Add(con); count++; } int cehckPurchase = 0; Purchase pr = new Purchase(); if (pr.AddPurchase(con, lastInsertedID)) { pr.AddPurchaseProduct(con, lastInsertedID); cehckPurchase++; } // t.Abort(); if (cehckPurchase > 0 && count > 0) { txScope.Complete();//transaction commit //MessageBox.Show("Products were added"); PopupNotifier pop = new PopupNotifier(); pop.ContentText = "Products Stock data stored to the system"; pop.TitleText = "Notification"; pop.Image = Resources.success_48; // or Image.FromFile(--Path--) pop.IsRightToLeft = false; pop.ContentHoverColor = Color.Teal; pop.Popup(); MetroMessageBox.Show(this, "Stock Details stored to the system. :-P ", "Successfull!", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); refresh(); } else { MetroMessageBox.Show(this, "Something Went Wrong. Please restrart the form and try again... ", "Unexpected Interuption!", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop); } } else { // t.Abort(); MetroMessageBox.Show(this, "Something Went Wrong. Please restrart the form and try again... ", "Unexpected Interuption!", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop); } }//end of using statement } } catch (Exception ex) { //t.Abort(); MetroMessageBox.Show(this, ex.Message, "System Error!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } finally { // t.Abort(); } }
public void RemoveWhenDifferentNotificationsTriggeredShouldSendEachNotificationOnce() { Product initialtestProduct = new Product("apricot", 10); string notifiedProduct = null; int notifiedQuantity = -1; int numberOfNotifications = 0; Action <Product> notification = product => { notifiedProduct = product.Name; notifiedQuantity = product.Quantity; numberOfNotifications++; }; ProcessProduct testNotification = new ProcessProduct(notification); Stock stockTest = new Stock(testNotification); stockTest.Add(initialtestProduct); Product productToRemove = new Product("apricot", 1); Assert.True(stockTest.Remove(productToRemove)); Assert.Equal(9, stockTest.Check(initialtestProduct)); Assert.Equal(initialtestProduct.Name, notifiedProduct); Assert.Equal(9, notifiedQuantity); Assert.Equal(1, numberOfNotifications); // Second Remove, no notification sent Assert.True(stockTest.Remove(productToRemove)); Assert.Equal(8, stockTest.Check(initialtestProduct)); Assert.Equal(initialtestProduct.Name, notifiedProduct); Assert.Equal(9, notifiedQuantity); Assert.Equal(1, numberOfNotifications); // Third Remove, second notification sent (less than 5 products) productToRemove.Quantity = 4; Assert.True(stockTest.Remove(productToRemove)); Assert.Equal(4, stockTest.Check(initialtestProduct)); Assert.Equal(initialtestProduct.Name, notifiedProduct); Assert.Equal(4, notifiedQuantity); Assert.Equal(2, numberOfNotifications); // Fourth Remove, no notification sent productToRemove.Quantity = 2; Assert.True(stockTest.Remove(productToRemove)); Assert.Equal(2, stockTest.Check(initialtestProduct)); Assert.Equal(initialtestProduct.Name, notifiedProduct); Assert.Equal(4, notifiedQuantity); Assert.Equal(2, numberOfNotifications); // Fifth Remove, third notification sent (less than 2 products) productToRemove.Quantity = 1; Assert.True(stockTest.Remove(productToRemove)); Assert.Equal(1, stockTest.Check(initialtestProduct)); Assert.Equal(initialtestProduct.Name, notifiedProduct); Assert.Equal(1, notifiedQuantity); Assert.Equal(3, numberOfNotifications); // Fourth Remove, no notification sent Assert.True(stockTest.Remove(productToRemove)); Assert.Equal(0, stockTest.Check(initialtestProduct)); Assert.Equal(initialtestProduct.Name, notifiedProduct); Assert.Equal(1, notifiedQuantity); Assert.Equal(3, numberOfNotifications); }