public Engine(ENGINE inType, int inMaxPower, List <int> inAngles) { type = inType; maxPower = inMaxPower; foreach (int angle in inAngles) { angles.Add(angle); } if (type == ENGINE.TREBUCHET) { elevation = trebuchetElevation; } }
public Engine(ENGINE entity = null) { if (entity == null) { return; } Id = entity.ID; Volume = entity.VOLUME; Fuels = entity.ENGINE_FUEL .Where(x => Id == x.ENGINE_ID) .Select(x => new Fuel(x.FUEL)) .ToList(); }
//static methods public static void SetEngine(ENGINE inEngine) { selectedEngine = inEngine; }
public CAR(string model, ENGINE engine, int?weight, string color) : this(model, engine) { this.weight = weight; this.color = color; }
public CAR(string model, ENGINE engine, string color) : this(model, engine) { this.color = color; }
public CAR(string model, ENGINE engine, int?weight) : this(model, engine) { this.weight = weight; }
public CAR(string model, ENGINE engine) { this.model = model; this.engine = engine; }
static void Main(string[] args) { int count = int.Parse(Console.ReadLine()); List <ENGINE> engines = new List <ENGINE>(); List <CAR> cars = new List <CAR>(); for (int i = 0; i < count; i++) { var tokens = Console.ReadLine().Split(' '); string model = tokens[0]; int power = int.Parse(tokens[1]); if (tokens.Length == 2) { engines.Add(new ENGINE(model, power)); } else if (tokens.Length == 3) { if (tokens[2].All(Char.IsDigit)) { int displacement = int.Parse(tokens[2]); engines.Add(new ENGINE(model, power, displacement)); } else { string efficiency = tokens[2]; engines.Add(new ENGINE(model, power, efficiency)); } } else if (tokens.Length == 4) { int displacement = int.Parse(tokens[2]); string efficiency = tokens[3]; engines.Add(new ENGINE(model, power, displacement, efficiency)); } } count = int.Parse(Console.ReadLine()); for (int i = 0; i < count; i++) { var tokens = Console.ReadLine().Split(' '); string model = tokens[0]; ENGINE engine = engines.First(e => e.Model == tokens[1]); if (tokens.Length == 2) { cars.Add(new CAR(model, engine)); } else if (tokens.Length == 3) { if (tokens[2].All(Char.IsDigit)) { int weight = int.Parse(tokens[2]); cars.Add(new CAR(model, engine, weight)); } else { string color = tokens[2]; cars.Add(new CAR(model, engine, color)); } } else if (tokens.Length == 4) { int weight = int.Parse(tokens[2]); string color = tokens[3]; cars.Add(new CAR(model, engine, weight, color)); } } cars.ForEach(Console.WriteLine); }