//creates the standard number of shares for an airline public static void CreateStandardAirlineShares(Airline airline, double sharePrice) { var rnd = new Random(); const int numberOfShares = 10000; int airlinePercentShares = rnd.Next(55, 65); airline.Shares = new List<AirlineShare>(); int airlineShares = (numberOfShares/100)*airlinePercentShares; //airline shares lock (airline.Shares) { for (int i = 0; i < airlineShares; i++) { var share = new AirlineShare(airline, sharePrice); airline.Shares.Add(share); } //'free' shares for (int i = airlineShares; i < numberOfShares; i++) { var share = new AirlineShare(null, sharePrice); airline.Shares.Add(share); } } }
//adds a number of shares to an airline public static void AddAirlineShares(Airline airline, int shares, double sharePrice) { for (int i = 0; i < shares; i++) { var share = new AirlineShare(null, sharePrice); airline.Shares.Add(share); } }