public TicketingAgency(Park park, MultiCellBuffer mcb, int id) { this.park = park; this.mcb = mcb; this.id = id; creditCardNumber = new Random().Next(5000, 7000); }
private static readonly int N = 5; // number of ticketing agencies static void Main(string[] args) { MultiCellBuffer mcb = new MultiCellBuffer(); Park park = new Park(mcb); // create park with multicell buffer Thread parkThread = new Thread(new ThreadStart(park.runParkThread)); parkThread.Name = 1.ToString(); parkThread.Start(); for (int i = 0; i < N; i++) //N ticketing agency threads will be created { TicketingAgency agencyThread = new TicketingAgency(park, mcb, i + 1); // create each ticketAgency with same buffer as the park Park.priceCut += new priceCutEvent(agencyThread.ticketsOnSale); // add the new Ticketing agency to the priceCutEvent Thread thread = new Thread(new ThreadStart(agencyThread.priceChecker)); thread.Name = (i + 1).ToString(); thread.Start(); } }
public Park(MultiCellBuffer mcb) { numPriceCuts = 0; pm = new PricingModel(); this.mcb = mcb; }