Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace car_shop
- {
- class car
- {
- string brand;
- double capacity;
- double price;
- double maxspeed;
- int attribute;
- public void input(int n)
- {
- string s;
- double b, d;
- Console.WriteLine("Enter brand of {0} car", n + 1);
- brand = Console.ReadLine();
- Console.WriteLine("Enter it is capacity");
- s = Console.ReadLine();
- capacity = Convert.ToDouble(s);
- Console.WriteLine("Enter it is price");
- b = Convert.ToInt32(Console.ReadLine());
- price = Convert.ToDouble(b);
- Console.WriteLine("Enter it is maxspeed");
- d = Convert.ToInt32(Console.ReadLine());
- maxspeed = Convert.ToDouble(d);
- }
- public void analyses(ref double desire_price, ref double desire_capacity, ref double desire_maxspeed)
- {
- if (price <= desire_price && capacity <= desire_capacity && maxspeed <= desire_maxspeed)
- attribute = 1;
- }
- public void output(int n)
- {
- if (attribute != 0)
- {
- Console.WriteLine("The car number {0} is suitable for you:", n + 1);
- Console.WriteLine("brand is '{0}' price is {1} capacity is {2} maxspeed is {3}", brand, price, capacity, maxspeed);
- }
- else
- Console.WriteLine("The {0} car is it not suitable for you ", n + 1);
- }
- }
- class Program
- {
- public static void Main(string[] args)
- {
- string s;
- double b, d;
- int count_of_cars;
- Console.WriteLine("Enter count_of_cars");
- s = Console.ReadLine();
- count_of_cars = Convert.ToInt32(s);
- car[] q = new car[count_of_cars];
- for (int i = 0; i < q.Length; i++)
- {
- q[i] = new car();
- q[i].input(i);
- }
- double desire_price;
- double desire_capacity;
- double desire_maxspeed;
- Console.WriteLine("=========:Filter:=========");
- Console.WriteLine("Enter desire capacity");
- s = Console.ReadLine();
- desire_capacity = Convert.ToDouble(s);
- Console.WriteLine("Enter desire price");
- b = Convert.ToInt32(Console.ReadLine());
- desire_price = Convert.ToDouble(b);
- Console.WriteLine("Enter desire maxspeed");
- d = Convert.ToInt32(Console.ReadLine());
- desire_maxspeed = Convert.ToDouble(d);
- for (int i = 0; i<q.Length;i++)
- {
- q[i].analyses(ref desire_capacity, ref desire_price, ref desire_maxspeed );
- q[i].output(i);
- }
- Console.WriteLine("Finish");
- Console.Write("Press any key to continue . . .");
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement