Skip to content

Instantly share code, notes, and snippets.

@profesor79
Created October 23, 2017 20:51
Show Gist options
  • Save profesor79/7964b047b40371d7007d01bcbeaa96f1 to your computer and use it in GitHub Desktop.
Save profesor79/7964b047b40371d7007d01bcbeaa96f1 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
namespace maaaa
{
public class Item
{
public string Name { get; set; }
public double Priec { get; set; }
public int Index { get; set; }
}
public class Stock : Item
{
public int StockValue { get; set; }
public void AddToStock(int numberOfItem)
{
StockValue += numberOfItem;
}
public bool RemoveFromStock(int numberOfItem)
{
if (StockValue >= numberOfItem)
{
StockValue -= numberOfItem;
return true;
}
return false;
}
}
public class Shop
{
private Dictionary <int, Stock> _stock = new Dictionary <int, Stock>();
public Dictionary <int, Stock> GetStockState()
{
return _stock;
}
public bool AddNewItem(Item product, int amount)
{
if(_stock.ContainsKey(product.Index)){
return false;
}
int newKey = _stock.Count+1;
Stock newItem = new Stock{
StockValue = amount,
Name = product.Name,
Index = newKey,
Priec = product.Priec
};
_stock.Add(newKey, newItem);
return false;
}
public bool SellItem(Item product, int Amount)
{
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment