Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Xml.Linq;
- using static System.Console;
- /*#49
- Создать приложение для учета данных автосалона, в котором есть следующие элементы:
- 1. Автомобиль со следующими атрибутами: высота, стоимость, мощность двигателя, длина, название, модель, дата последнего тех. обслуживания, год выпуска, тип привода, цвет.
- 2. Автосалон со следующими атрибутами: прибыль, название, дата открытия, класс.
- 3. Рабочий со следующими атрибутами: зарплата, премия, отчество, имя, email, фамилия, дата приема на работу, дата рождения, должность.
- Также приложение должно реализовывать следующий функционал:
- 1. Самый старый магазин это ...
- 2. Вывести список автомобилей, где <тип_кпп> равняется Х
- 3. Реализовать автоматическое заполнение данными для автомобиля*/
- namespace BaseAvtosalon
- {
- class Program
- {
- static List<Employee> CEmployee = new List<Employee> { }; // Список подчиненных
- static List<Saloon> CSaloon = new List<Saloon> { }; // Список салонов
- static List<Auto> CAuto = new List<Auto> { };
- public static int CLC = 0; // slaoon - счётчик для динамического создания экземпляров класса Cheifs
- public static int ELC = 0; // Employees Lisc Counter - счётчик для динамического создания экземпляров класса Employees
- public static int ALC = 0; // auto
- class Employee
- {
- private int _Age;
- private int _Salary;
- private int _Premia;
- private string _Name;
- private string _Surname;
- private string _Thirdname;
- private string _Dr;
- private string _Dataraboty;
- private string _Department;
- public string Name
- {
- get { return _Name; }
- set
- {
- _Name = value;
- }
- }
- public string Surname
- {
- get { return _Surname; }
- set
- {
- _Surname = value;
- }
- }
- public string Thirdname
- {
- get { return _Thirdname; }
- set
- {
- _Thirdname = value;
- }
- }
- public int Age
- {
- get { return _Age; }
- set
- {
- if (value > 0)
- {
- _Age = value;
- }
- else
- {
- WriteLine(new String('-', 20));
- WriteLine("Age must be positive");
- WriteLine(new String('-', 20));
- Environment.Exit(1);
- }
- }
- }
- public int Premia
- {
- get { return _Premia; }
- set
- {
- if (value > 0)
- {
- _Premia = value;
- }
- else
- {
- WriteLine(new String('-', 20));
- WriteLine("Premia must be positive");
- WriteLine(new String('-', 20));
- Environment.Exit(1);
- }
- }
- }
- public int Salary
- {
- get { return _Salary; }
- set
- {
- if (value > 0)
- {
- _Salary = value;
- }
- else
- {
- WriteLine(new String('-', 23));
- WriteLine("Salary must be positive");
- WriteLine(new String('-', 23));
- Environment.Exit(1);
- }
- }
- }
- public string Dr
- {
- get { return _Dr; }
- set
- {
- _Dr = value;
- }
- }
- public string Dataraboty
- {
- get { return _Dataraboty; }
- set
- {
- _Dataraboty = value;
- }
- }
- public string Department
- {
- get { return _Department; }
- set { _Department = value; }
- }
- }
- class Auto
- {
- private int _Height;
- private int _Cost;
- private int _Length;
- private int _Hp;
- private string _Birth;
- private string _Date;
- private string _Privod;
- private string _Color;
- private string _Name;
- private string _Model;
- private string _Tipkpp;
- public int Height
- {
- get { return _Height; }
- set
- {
- _Height = value;
- }
- }
- public int Cost
- {
- get { return _Cost; }
- set
- {
- _Cost = value;
- }
- }
- public int Length
- {
- get { return _Length; }
- set
- {
- _Length = value;
- }
- }
- public int Hp
- {
- get { return _Hp; }
- set
- {
- _Hp = value;
- }
- }
- public string Birth
- {
- get { return _Birth; }
- set
- {
- _Birth = value;
- }
- }
- public string Date
- {
- get { return _Date; }
- set
- {
- _Date = value;
- }
- }
- public string Privod
- {
- get { return _Privod; }
- set
- {
- _Privod = value;
- }
- }
- public string Color
- {
- get { return _Color; }
- set
- {
- _Color = value;
- }
- }
- public string Name
- {
- get { return _Name; }
- set
- {
- _Name = value;
- }
- }
- public string Model
- {
- get { return _Model; }
- set
- {
- _Model = value;
- }
- }
- public string Tipkpp
- {
- get { return _Tipkpp; }
- set
- {
- _Tipkpp = value;
- }
- }
- }
- class Saloon
- {
- private int _Profit;
- private string _Name;
- private string _Class;
- private int _Birth;
- public int Profit
- {
- get { return _Profit; }
- set
- {
- _Profit = value;
- }
- }
- public string Name
- {
- get { return _Name; }
- set
- {
- _Name = value;
- }
- }
- public string Class
- {
- get { return _Class; }
- set
- {
- _Class = value;
- }
- }
- public int Birth
- {
- get { return _Birth; }
- set
- {
- _Birth = value;
- }
- }
- }
- static void AddAuto()
- {
- /* private int _Height;
- private int _Cost;
- private int _Length;
- private int _Hp;
- private string _Birth;
- private string _Date;
- private string _Privod;
- private string _Color;
- private string _Name;
- private string _Model;
- private string _Tipkpp;*/
- WriteLine("Write cost of car");
- CAuto[ALC].Cost = Convert.ToInt32(ReadLine());
- WriteLine("Write height of car");
- CAuto[ALC].Height = Convert.ToInt32(ReadLine());
- WriteLine("Write length of car");
- CAuto[ALC].Length= Convert.ToInt32(ReadLine());
- WriteLine("Write profit of company");
- CAuto[ALC].Hp = Convert.ToInt32(ReadLine());
- WriteLine("Write profit of company");
- CAuto[ALC].Birth = ReadLine();
- WriteLine("Write profit of company");
- CAuto[ALC].Date = ReadLine();
- WriteLine("Write profit of company");
- CAuto[ALC].Privod = ReadLine();
- WriteLine("Write profit of company");
- CAuto[ALC].Color = ReadLine();
- WriteLine("Write profit of company");
- CAuto[ALC].Name = ReadLine();
- WriteLine("Write profit of company");
- CAuto[ALC].Model = ReadLine();
- WriteLine("Write profit of company");
- CAuto[ALC].Tipkpp = ReadLine();
- }
- static void AddSaloon()
- {
- CSaloon.Add(new Saloon());
- WriteLine("Write profit of company");
- CSaloon[CLC].Profit = Convert.ToInt32(ReadLine());
- WriteLine("Write name of company");
- CSaloon[CLC].Name = ReadLine();
- WriteLine("Write birth of company");
- CSaloon[CLC].Birth = Convert.ToInt32(ReadLine());
- WriteLine("Write class of company");
- CSaloon[CLC].Class = ReadLine();
- CLC++;
- }
- static void AddEmployee()
- {
- CEmployee.Add(new Employee());
- WriteLine("Write first name");
- CEmployee[ELC].Name = ReadLine();
- WriteLine("Write second name");
- CEmployee[ELC].Surname = ReadLine();
- WriteLine("Write third name");
- CEmployee[ELC].Thirdname = ReadLine();
- WriteLine("Write age of employee");
- CEmployee[ELC].Age = Convert.ToInt32(ReadLine());
- WriteLine("Write salary of employee");
- CEmployee[ELC].Salary = Convert.ToInt32(ReadLine());
- WriteLine("Write premia of employee");
- CEmployee[ELC].Premia = Convert.ToInt32(ReadLine());
- WriteLine("Write birthday");
- CEmployee[ELC].Dr = ReadLine();
- WriteLine("Write date of work");
- CEmployee[ELC].Dataraboty = ReadLine();
- WriteLine("Write department of employee");
- CEmployee[ELC].Department = ReadLine();
- ELC++;
- }
- static bool AlreadyExist(string Name,string Surname,string Thirdname)
- {
- int local_i = 0;
- foreach (Employee Hmn in CEmployee)
- {
- if (Hmn.Name == Name && Hmn.Surname == Surname && Hmn.Thirdname == Thirdname)
- {
- return true;
- }
- else
- {
- local_i++;
- }
- }
- return false;
- }
- static void InfoByName()
- {
- WriteLine("Write first, second and third name of person:");
- string[] tmp = ReadLine().Split().ToArray();
- string person1 = tmp[0];
- string person2 = tmp[1];
- string person3 = tmp[2];
- if (AlreadyExist(person1,person2,person3) == false)
- {
- WriteLine("Person are not exist");
- }
- foreach (Employee Hmn in CEmployee)
- {
- if (person1 == Hmn.Name && person2 == Hmn.Surname && person3 == Hmn.Thirdname)
- {
- WriteLine(new String('-', 20));
- WriteLine("Name: {0}\nSurname:{1}\nThirdname{2}\nAge: {3}\nSalary: {4}\nDepartment: {5}\nBirthday{6}\nDate work{7}\nPremia:{8}\n", Hmn.Name,Hmn.Surname,Hmn.Thirdname, Hmn.Age, Hmn.Salary, Hmn.Department, Hmn.Dr, Hmn.Dataraboty, Hmn.Premia);
- WriteLine(new String('-', 20));
- break;
- }
- }
- }
- static void InfoByType()
- {
- Console.WriteLine("Write typy of KPP");
- string kpp = Console.ReadLine();
- foreach (Auto hauto in CAuto)
- {
- if (kpp == "mechanical")
- {
- WriteLine(new String('-', 20));
- WriteLine("Cost:{0}\nLength{1}\nHP:{2}\nBirthdate:{3}\nDate repair:{4}\nType privod:{5}\nColor:{6}\nName:{7}\nModel{8}\n", hauto.Cost, hauto.Length,hauto.Hp,hauto.Birth,hauto.Date,hauto.Privod,hauto.Color,hauto.Name,hauto.Model);
- WriteLine(new String('-', 20));
- }
- else if (kpp == "auto")
- {
- WriteLine(new String('-', 20));
- WriteLine("Cost:{0}\nLength{1}\nHP:{2}\nBirthdate:{3}\nDate repair:{4}\nType privod:{5}\nColor:{6}\nName:{7}\nModel{8}\n", hauto.Cost, hauto.Length, hauto.Hp, hauto.Birth, hauto.Date, hauto.Privod, hauto.Color, hauto.Name, hauto.Model);
- WriteLine(new String('-', 20));
- }
- else if (kpp == "variator")
- {
- WriteLine(new String('-', 20));
- WriteLine("Cost:{0}\nLength{1}\nHP:{2}\nBirthdate:{3}\nDate repair:{4}\nType privod:{5}\nColor:{6}\nName:{7}\nModel{8}\n", hauto.Cost, hauto.Length, hauto.Hp, hauto.Birth, hauto.Date, hauto.Privod, hauto.Color, hauto.Name, hauto.Model);
- WriteLine(new String('-', 20));
- }
- else
- {
- Console.WriteLine("Wrong type of KPP");
- }
- }
- }
- static void Old()
- {
- int data = 0;
- string name = null;
- foreach (Saloon sln in CSaloon)
- {
- /* private int _Profit;
- private string _Name;
- private string _Class;
- private string _Birth;*/
- if (data < sln.Birth)
- {
- data = sln.Birth;
- name = sln.Name;
- break;
- }
- }
- Console.WriteLine(name);
- }
- static void Main(string[] args)
- {
- label1:
- WriteLine(new String('-', 21) + "\nPrint type of command\n1:Add Auto" +
- "\n2:Add Employee " +
- "\n3:Get Info via Name\n4:Get Info via Type KPP\n5:Get elder saloon\n6:Add Saloon\n" + new String('-', 21));
- int typeOfCommand = Convert.ToInt32(ReadLine());
- switch (typeOfCommand)
- {
- case 1:
- AddAuto();
- goto label1;
- break;
- case 2:
- AddEmployee();
- goto label1;
- break;
- case 3:
- InfoByName();
- goto label1;
- break;
- case 4:
- InfoByType();
- goto label1;
- break;
- case 5:
- Old();
- goto label1;
- break;
- case 6:
- AddSaloon();
- goto label1;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement