public static void Main() { Random random = new Random(); // создаем рандомных пассажиров. PassengerQueue pq = new PassengerQueue(); for (int i = 0; i < 20; i++) { if (i % 5 == 0) { PassengerWithChildren p = new PassengerWithChildren(); p.Name = random.Next(1000, 2000).ToString(); p.LastName = random.Next(30000, 40000).ToString(); p.NumberOfChildren = random.Next(1, 3); p.Age = random.Next(18, 80); p.IsNewBorn = random.Next(100) <= 50 ? true : false; pq.AddToQueue(p); } else { Passenger p = new Passenger(); p.Name = random.Next(1000, 2000).ToString(); p.LastName = random.Next(30000, 40000).ToString(); p.Age = random.Next(18, 80); pq.AddToQueue(p); } } pq.StartServingQueue(); }
public static void Main() { PassengerQueue queue = new PassengerQueue(); for (int i = 0; i < rnd.Next(10, 20); i++) { Passenger pass; if (rnd.Next(0, 2) == 1) { pass = new Passenger(); pass.Name = rnd.Next(0, 100000000).ToString(); pass.LastName = rnd.Next(0, 100000000).ToString(); pass.Age = rnd.Next(0, 100); queue.AddToQueue(pass); } else { pass = new PassengerWithChildren(); pass.Name = rnd.Next(0, 100000000).ToString(); pass.LastName = rnd.Next(0, 100000000).ToString(); pass.Age = rnd.Next(0, 100); ((PassengerWithChildren)pass).NumberOfChildren = rnd.Next(0, 20); queue.AddToQueue(pass); } queue.StartServingQueue(); } }
public static void Main() { Random rnd = new Random(); PassengerQueue pq = new PassengerQueue(); for (int i = 0; i < 5; i++) { Passenger passenger = new Passenger(); passenger.Name = rnd.Next(100, 1000).ToString(); passenger.LastName = rnd.Next(1000, 10000).ToString(); passenger.Age = rnd.Next(18, 100); pq.AddToQueue(passenger); } for (int i = 0; i < 5; i++) { PassengerWithChildren passenger = new PassengerWithChildren(); passenger.Name = rnd.Next(100, 1000).ToString(); passenger.LastName = rnd.Next(1000, 10000).ToString(); passenger.Age = rnd.Next(18, 100); passenger.NumberOfChildren = rnd.Next(1, 11); if (rnd.Next(0, 2) == 0) { passenger.IsNewBorn = false; } else { passenger.IsNewBorn = true; } pq.AddToQueue(passenger); } pq.StartServingQueue(); }
public static void Main() { PassengerQueue pQ = new PassengerQueue(); Random rnd = new Random(); for (int i = 0; i < 7; i++) { int withChildren = rnd.Next(0, 2); if (withChildren == 1) { PassengerWithChildren pc = new PassengerWithChildren(); int num = rnd.Next(3, 8); string str = ""; for (int j = 0; j < num; j++) { str += (char)rnd.Next(97, 123); } pc.Name = str; num = rnd.Next(3, 8); str = ""; for (int j = 0; j < num; j++) { str += (char)rnd.Next(97, 123); } pc.LastName = str; pc.Age = rnd.Next(30, 51); pc.NumberOfChildren = rnd.Next(1, 5); pc.ageOfTheYoungest = rnd.Next(1, 20); pQ.AddToQueue(pc); Console.WriteLine(pc); } else { Passenger pc = new Passenger(); int num = rnd.Next(3, 8); string str = ""; for (int j = 0; j < num; j++) { str += (char)rnd.Next(97, 123); } pc.Name = str; num = rnd.Next(3, 8); str = ""; for (int j = 0; j < num; j++) { str += (char)rnd.Next(97, 123); } pc.LastName = str; pc.Age = rnd.Next(18, 86); pQ.AddToQueue(pc); Console.WriteLine(pc); } } Console.WriteLine(); Console.WriteLine(); pQ.StartServingQueue(); }
public static void Main() { int n1 = int.Parse(Console.ReadLine()), n2 = int.Parse(Console.ReadLine()); PassengerQueue q = new PassengerQueue(); // Обычные пассажиры. for (int i = 0; i < n1; ++i) { try { Random rand = new Random(); Passenger newPassenger = new Passenger(); newPassenger.Age = rand.Next(0, 100); // Рандомное имя. newPassenger.Name = "Chel"; newPassenger.LastName = "c"; } catch (ArgumentException e) { Console.WriteLine("There is a problem with passenger №" + i + ":\n" + e.Message); } } // С детьми. for (int i = 0; i < n2; ++i) { try { Random rand = new Random(); PassengerWithChildren newPassenger = new PassengerWithChildren(); newPassenger.Age = rand.Next(0, 100); // Рандомное имя. newPassenger.Name = "Chel with children"; newPassenger.LastName = "c"; newPassenger.NumberOfChildren = rand.Next(0, 10); } catch (ArgumentException e) { Console.WriteLine("There is a problem with passenger №" + i + ":\n" + e.Message); } } q.StartServingQueue(); }
public static void Main() { PassengerQueue queue = new PassengerQueue(); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; ++i) { Passenger p = new Passenger(); p.Name = "qwerty"; p.LastName = "uiop"; p.Age = rnd.Next(0, 100); queue.AddToQueue(p); } queue.StartServingQueue(); }
public static void Main() { PassengerQueue queue = new PassengerQueue(); StreamReader streamReader = new StreamReader("cvs.txt"); while (!streamReader.EndOfStream) { string input = streamReader.ReadLine(); string[] data = input.Split(' ', StringSplitOptions.RemoveEmptyEntries); if (data.Length == 3) { queue.AddToQueue(new Passenger(data[0], data[1], uint.Parse(data[2]))); } else if (data.Length == 5) { queue.AddToQueue(new PassengerWithChildren(data[0], data[1], uint.Parse(data[2]), uint.Parse(data[3]), (new Random().Next(0, 2) == 0) ? true : false)); } else { throw new Exception(); } } }