Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace VehicleCatalogue
- {
- class StartUp
- {
- static void Main(string[] args)
- {
- List<Car> cars = new List<Car>();
- List<Truck> trucks = new List<Truck>();
- string[] input = Console.ReadLine().Split('/');
- while (input[0] != "end")
- {
- if (input[0] == "Car")
- {
- Car car = new Car();
- car.Brand = input[1];
- car.Model = input[2];
- car.HorsePower = input[3];
- cars.Add(car);
- }
- else
- {
- Truck truck = new Truck();
- truck.Brand = input[1];
- truck.Model = input[2];
- truck.Weight = input[3];
- trucks.Add(truck);
- }
- input = Console.ReadLine().Split('/');
- }
- cars = cars.OrderBy(x => x.Brand).ToList();
- trucks = trucks.OrderBy(x => x.Brand).ToList();
- if (cars.Count != 0)
- {
- Console.WriteLine("Cars:");
- foreach (Car car in cars)
- {
- Console.WriteLine($"{car.Brand}: { car.Model} - { car.HorsePower}hp");
- }
- }
- if (trucks.Count != 0)
- {
- Console.WriteLine("Trucks:");
- foreach (Truck truck in trucks)
- {
- Console.WriteLine($"{ truck.Brand}: { truck.Model} - { truck.Weight}kg");
- }
- }
- }
- }
- class Truck
- {
- public string Brand { get; set; }
- public string Model { get; set; }
- public string Weight { get; set; }
- }
- class Car
- {
- public string Brand { get; set; }
- public string Model { get; set; }
- public string HorsePower { get; set; }
- }
- class Catalogue
- {
- public List<Car> Cars { get; set; }
- public List<Truck> Trucks { get; set; }
- Catalogue()
- {
- Cars = new List<Car>();
- Trucks = new List<Truck>();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement