No Description

aleukhin 5e4595d415 1com 8 months ago
ConsoleApp1 5e4595d415 1com 8 months ago
ConsoleApp3 5e4595d415 1com 8 months ago
.gitignore.txt 5e4595d415 1com 8 months ago
readme.md 5e4595d415 1com 8 months ago

readme.md

ООП

АВТОСЕРВИС "ВОЛШЕБНИК НАШЕЛ КОЛЕСА"

using System;

class product
{
    public string Name { get; set; }
    public int Price { get; set;  }

    public product(string name, int price)
    {
        Name = name;
        Price = price;
    }

    public void Display()
    {
        Console.WriteLine($"{Name} - ${Price}");
    }
}

public class car
{
    public string Name { get; set; }
    public car(string name)
    {
        Name = name;
    }
    public void Display()
    {
        Console.WriteLine($"для машины {Name}");

    }
}

class workers
{
    public string LastName { get; set; }

    public workers(string name)
    {
        LastName = name;
    }

    public void Order(List<product> products, List<car>cars)
    {
        Console.WriteLine($"{LastName} оказал услугу по починке: ");
        foreach (var product in products)
        {
            product.Display();
        }

        foreach (var car in cars)
        {
            car.Display();

        }
        
    }
}
class Program
{
    static void Main(string[] args)
    {
        product product1 = new product("Коробас", 56000);
        product product2 = new product("Колодки", 12500);
        product product3 = new product("Подвеска", 85000);
        product product4 = new product("Выхлоп", 9700);
        product product5 = new product("Заварка дна", price:6000);

        car car1 = new car("Бэха");
        car car2 = new car("ВЗАД 2110");
        workers meat1 = new workers("мишаня");
        workers meat2 = new workers("миша");
        workers meat3 = new workers("миха");
        workers meat4= new workers("маша");


        List<product> products1 = new List<product> { product2, product4 };
        List<product> products2 = new List<product> { product1, product3, product5 };
            List<car> cars1 = new List<car> { car1 };
            List<car> cars2 = new List<car> { car2 };
            
            meat1.Order(products1,cars1);
            
            meat4.Order(products2, cars2);
    }
}

вывод:

мишаня оказал услугу по починке:
Колодки - $12500               
Выхлоп - $9700                 
для машины Бэха                
миша оказал услугу по починке: 
Коробас - $56000               
Подвеска - $85000              
Заварка дна - $6000            
для машины ВЗАД 2110