Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Класа Car:
- namespace CarsProject
- {
- public class Car
- {
- private string brand;
- private string model;
- private string year;
- private string color;
- private double price;
- public Car(string carBrand,
- string carModel,
- string carYear,
- string carColor,
- double carPrice)
- {
- this.brand = carBrand;
- this.model = carModel;
- this.year = carYear;
- this.color = carColor;
- this.price = carPrice;
- }
- public void printInfo(Car car)
- {
- Console.WriteLine("Brand: {0}\nModel: {1}\n", car.brand, car.model);
- }
- }
- }
- //Главен клас:
- namespace CarsProject
- {
- public class Program
- {
- static void Main(string[] args)
- {
- Car car1 = new Car(
- "Merc", "G65", "2001", "Yellow", 1000
- );
- Car car2 = new Car(
- "VW", "Golf 4", "2004", "Red", 2000
- );
- car1.printInfo(car1);
- Console.WriteLine();
- car2.printInfo(car2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement