public MyWindow() { InitializeComponent(); MyPark = new ParkOfCars(); MyPark.AddSimpleCar("ladasedan", "м371ак", 400000, 7, 175); MyPark.AddGoodCar("subaru_forester", "н136ор", 1800000, 8, 198); MyPark.AddVIPCar("mers_cls", "е777кх", 5000000, 5, 250); Cost_label.Content = null; Cost_label.Content = MyPark.GetCost(); }
private void Add_Click(object sender, RoutedEventArgs e) { string Name = NameTextBox.Text; string Number = NumberTextBox.Text; int Price = Convert.ToInt32(PriceTextBox.Text); int Fuel = Convert.ToInt32(FuelTextBox.Text); int Speed = Convert.ToInt32(SpeedTextBox.Text); if (SimpleCarRBut.IsChecked == true) { MyPark.AddSimpleCar(Name, Number, Price, Fuel, Speed); } else if (GoodCarRBut.IsChecked == true) { MyPark.AddGoodCar(Name, Number, Price, Fuel, Speed); } else { MyPark.AddVIPCar(Name, Number, Price, Fuel, Speed); } }
static void Main(string[] args) { ParkOfCars MyPark = new ParkOfCars(); while (true) { Console.WriteLine("1 - Add car, 2 - GetCost, 3 - Sort, 4 = FindCar"); int Action = Convert.ToInt32(Console.ReadLine()); switch (Action) { case 1: Console.WriteLine("Name: "); string name = Console.ReadLine(); Console.WriteLine("Number: "); string number = Console.ReadLine(); Console.WriteLine("Price: "); int price = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("FuelConsumption: "); int fuelconsumption = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Speed: "); int speed = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("1 - VIP, 2 - Good, 3 - Simple"); int TypCar = Convert.ToInt32(Console.ReadLine()); switch (TypCar) { case 1: MyPark.AddVIPCar(name, number, price, fuelconsumption, speed); break; case 2: MyPark.AddSimpleCar(name, number, price, fuelconsumption, speed); break; case 3: MyPark.AddSimpleCar(name, number, price, fuelconsumption, speed); break; default: Console.WriteLine("adding error"); break; } break; case 2: Console.WriteLine(MyPark.GetCost()); break; case 3: Console.WriteLine(MyPark.GetSortedCars()); break; case 4: Console.WriteLine("min"); int min = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("max"); int max = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(MyPark.GetSpeedCar(min, max)); break; } } }