public Airplane(int iD, int status, List <IPassenger> passengers, StandardRoute route, List <IBaggage> baggage, double fuel, double fuelMax, bool defrosted, List <IFood> food) : this(iD) { Id = iD; if (status != 0 && status != 10) { Status = 0; } else { Status = status; } if (passengers == null && status == 10) { // TODO: вызов генерации пассажиров (к Даниной системе) } else { Passengers = passengers; } Route = route; if (baggage == null && status == 10) { // TODO: вызов генерации багажа } else { Baggage = baggage; } if ((int)fuel == 0) { Fuel = _r.Next(50, 101); } else { Fuel = fuel; } if ((int)fuelMax == 0) { FuelMax = _r.Next(75, 101); if (FuelMax < Fuel) { FuelMax = Fuel; } } else { FuelMax = fuelMax; } Defrosted = defrosted; if (food == null && status == 10) { // TODO: вызов генерации еды } else { Food = food; } }
private static void CreateAirplane() { var creation = true; var status = 0; var passengers = new List <IPassenger>(); var baggage = new List <IBaggage>(); var fuel = 0.0; var fuelMax = 0.0; var defrosted = false; var food = new List <IFood>(); var route = new StandardRoute(); while (creation) { Console.Clear(); Console.WriteLine( $"1. Status (" + status + ")\n" + $"2. Add Passenger (" + JsonConvert.SerializeObject(passengers) + ")\n" + $"3. Change Route (" + JsonConvert.SerializeObject(route) + ")\n" + $"4. Add Baggage (" + JsonConvert.SerializeObject(baggage) + ")\n" + $"5. Fuel (" + fuel + ")\n" + $"6. FuelMax (" + fuelMax + ")\n" + $"7. Defrosted (" + defrosted + ")\n" + $"8. Add Food (" + JsonConvert.SerializeObject(food) + ")\n\n" + $"9. Create!\n" + $"0. Create with JSON!" ); var key = Convert.ToInt32(Console.ReadLine()); Console.Clear(); switch (key) { case 1: throw new NotImplementedException(); //Пассажир /*Console.WriteLine( * $"1. Passengers (" + JsonConvert.SerializeObject(passengers) + ")\n" + * $"2. Route" + JsonConvert.SerializeObject(route) + ")\n" + * $"3. Baggage (" + JsonConvert.SerializeObject(baggage) + ")\n" + * $"4. Fuel (" + fuel + ")\n" + * $"5. FuelMax (" + fuelMax + ")\n" + * $"6. Defrosted (" + defrosted.ToString() + ")\n" + * $"7. Food (" + JsonConvert.SerializeObject(food) + ")\n" + * $"0. Create!" * );*/ break; case 2: throw new NotImplementedException(); break; case 3: throw new NotImplementedException(); break; case 4: throw new NotImplementedException(); break; case 5: throw new NotImplementedException(); break; case 6: throw new NotImplementedException(); break; case 7: throw new NotImplementedException(); break; case 9: creation = false; throw new NotImplementedException(); break; case 0: creation = false; Console.WriteLine("Paste Json here:"); var airplane = JsonConvert.DeserializeObject <Airplane>(Console.ReadLine()); var serializedAirplane = JsonConvert.SerializeObject(airplane); Console.WriteLine("Final airplane:\n" + serializedAirplane); CreateAirplaneWithPost(serializedAirplane); break; default: continue; } } /* * { * "Id":3, * "Passengers":null, * "Baggage":null, * "Fuel":0.0, * "FuelMax":0.0, * "Defrosted":false, * "Food":null, * "Route":null * } */ }