Exemplo n.º 1
0
        public string Sell(string assetName, decimal amount)
        {
            decimal price = MarketProp.AssetPrice(assetName);

            IAsset asset = Factory.CreateAsset(assetName, price, amount);

            UserSession.User.Wallet.RemoveAsset(asset);
            UserSession.User.Wallet.Cash += price * amount;
            PrinterManager.PrintMarket(UserSession.User, MarketProp);
            return($"Succesfully selled {amount} {assetName} " + (amount > 1 ? "assets" : "asset"));
        }
Exemplo n.º 2
0
        public string Buy(string assetName, decimal amount)
        {
            decimal price = MarketProp.AssetPrice(assetName);

            if (UserSession.User.Wallet.Cash >= price * amount)
            {
                IAsset asset = Factory.CreateAsset(assetName, price, amount);
                UserSession.User.Wallet.AddAsset(asset);
                UserSession.User.Wallet.Cash -= price * amount;
            }
            else
            {
                throw new ArgumentException("You don't have enough funds for this purchase.");
            }
            PrinterManager.PrintMarket(UserSession.User, MarketProp);
            return($"Succesfully purchased {amount} {assetName} " + (amount > 1 ? "assets" : "asset"));
        }
Exemplo n.º 3
0
 public string EndDayTraiding()
 {
     MarketProp.UpdatePrices();
     PrinterManager.PrintMarket(UserSession.User, MarketProp);
     return("Trading day has ended!");
 }
Exemplo n.º 4
0
        public string EndDayTraiding()
        {
            MarketProp.UpdatePrices();

            return("Trading day has ended!");
        }