Esempio n. 1
0
 public void Sell(Player player, int numberOfShares)
 {
     // check if the player owns stock in this player
     var asset = this.Portfolio.Where (a => a.Player.Id == player.Id).FirstOrDefault();
     if (asset == null) {
         throw new ArgumentException ("You do not own shares in this player");
     }
     if (asset.NumberOfShares < numberOfShares) {
         throw new ArgumentException ("You do not own enough shares of this player.");
     }
 }
Esempio n. 2
0
        public void Buy(Player player, int numberOfShares)
        {
            // calculate the cost to make this buy
            var cost = player.StockValue * numberOfShares;

            // check if the trader has enough money
            if (this.NetWorth < cost) {
                throw new ArgumentException ("You do not have enough money to make this Buy");
            }

            // deduct the cost from the traders networth
            this.NetWorth -= cost;

            // add the asset to the traders portfolio
            var asset = new Asset (player, numberOfShares);
            this.Portfolio.Add (asset);
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            // create new player
            var nbarger = new Player ();
            nbarger.FirstName = "Nicholas";
            nbarger.MiddleName = "Clark";
            nbarger.LastName = "Barger";
            nbarger.DateOfBirth = DateTime.Parse ("02/12/1982");

            // set sport(s)
            var sport = new Sport (Sport.List.Football);
            nbarger.Sports.Add (sport);

            // begin ipo
            var amountOfShares = 10000;
            var pricePerShare = 25.00;
            nbarger.InitiatePublicOffering (amountOfShares, pricePerShare);

            // start trading
            StartTrading ();
        }