Program.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Магазин электронники
  2. var client1 = new Client("Иван", "Березов", 21, "+79938287424");
  3. var worker1 = new Worker("Анастасия", "Иванова", 32, 47000,"Менеджер");
  4. var worker2 = new Worker("Глеб", "Олехин", 27, 23000,"Продавец");
  5. var product1 = new Item("Iphone 13 Pro", 94999);
  6. var smartpones = new Category("Смартфон");
  7. product1.category = smartpones;
  8. Console.WriteLine($"{worker2.firstName} продал покупателю {client1.firstName} {product1.category.title} {product1.title} за {product1.price} рублей ");
  9. Console.WriteLine($"{worker1.position} {worker1.firstName} повысил зарпалту сотруднику {worker2.firstName} {worker2.lastName}.");
  10. public class Category
  11. {
  12. public string title { get; set; }
  13. public Category(string title)
  14. {
  15. this.title = title;
  16. }
  17. }
  18. public class Item
  19. {
  20. public string title { get; set; }
  21. public Category category { get; set; }
  22. public string description { get; set; }
  23. public double price { get; set; }
  24. public Item (string title, double price)
  25. {
  26. this.title = title;
  27. this.price = price;
  28. }
  29. }
  30. public abstract class Person
  31. {
  32. public string firstName { get; set; }
  33. public string lastName { get; set; }
  34. public int age { get; set; }
  35. public Person(string firstName, string lastName, int age)
  36. {
  37. this.firstName = firstName;
  38. this.lastName = lastName;
  39. this.age = age;
  40. }
  41. }
  42. public class Worker : Person
  43. {
  44. public double salary { get; set; }
  45. public string position { get; set; }
  46. public Worker(string firstName, string lastName, int age, double salary, string position) : base(firstName, lastName, age)
  47. {
  48. this.salary = salary;
  49. this.position = position;
  50. }
  51. }
  52. public class Client : Person
  53. {
  54. public string numberPhone { get; set; }
  55. public Client(string firstName, string lastName, int age, string numberPhone) : base(firstName, lastName, age)
  56. {
  57. this.numberPhone = numberPhone;
  58. }
  59. }