Advertisement
Guest User

Untitled

a guest
May 16th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. namespace Zadazcha
  2. {
  3. class Product
  4. {
  5. private string name;
  6. private string proizvoditel;
  7. private double price;
  8. public Product(string name, double price)
  9. {
  10. this.name = name;
  11. this.price = price;
  12. }
  13. public string Name
  14. {
  15. get { return name; }
  16. set { name = value; }
  17. }
  18. public string Proizvoditel
  19. {
  20. get { return proizvoditel; }
  21. set { proizvoditel = value; }
  22. }
  23. public double Price
  24. {
  25. get { return price; }
  26. set { price = value; }
  27. }
  28. }
  29. class Nasipni : Product
  30. {
  31. private string mEdinica;
  32. private double kolichestvo;
  33. public string MEdinica
  34. {
  35. get { return mEdinica; }
  36. set { mEdinica = value; }
  37. }
  38. public double Kolichestvo
  39. {
  40. get { return kolichestvo; }
  41. set { kolichestvo = value; }
  42. }
  43. public Nasipni(string name, double price) : base(name, price)
  44. {
  45. this.Name = name;
  46. this.Price = price;
  47. Console.WriteLine("{0} {1}", name, price);
  48. }
  49. public void Print()
  50. {
  51. Console.WriteLine("Name: {0} Price: {1}", Name, Price);
  52. }
  53. public double ProdazhnaCena(double price)
  54. {
  55. if (Kolichestvo >= 20 && MEdinica == "br")
  56. {
  57. Price = Price + (Price * 0.1) + (Price * 0.2);
  58. }
  59. else if (Kolichestvo >= 1 && MEdinica == "kg")
  60. {
  61. Price = Price + (Price * 0.1) + (Price * 0.2);
  62. }
  63. else
  64. {
  65. Price = Price + (Price * 0.18) + (Price * 0.2);
  66. }
  67. return Price;
  68. }
  69. }
  70. class Paketirani : Product
  71. {
  72. private string mEdinica;
  73. private double kolichestvo;
  74. public string MEdinica
  75. {
  76. get { return mEdinica; }
  77. set { mEdinica = value; }
  78. }
  79. public double Kolichestvo
  80. {
  81. get { return kolichestvo; }
  82. set { kolichestvo = value; }
  83. }
  84. public Paketirani(string name, double price) : base(name, price)
  85. {
  86. this.Name = name;
  87. this.Price = price;
  88. }
  89. public void Print()
  90. {
  91. Console.WriteLine("Name: {0} Price: {1}", Name, Price);
  92. }
  93. public double ProdazhnaCena(double price)
  94. {
  95. if (Kolichestvo >= 20 && MEdinica == "br")
  96. {
  97. Price = Price + (Price * 0.1) + (Price * 0.2);
  98. }
  99. else if (Kolichestvo >= 1 && MEdinica == "kg")
  100. {
  101. Price = Price + (Price * 0.1) + (Price * 0.2);
  102. }
  103. else
  104. {
  105. price = Price + (Price * 0.18) + (Price * 0.2);
  106. }
  107. return Price;
  108. }
  109. }
  110. class Program
  111. {
  112. static void Main(string[] args)
  113. {
  114. Nasipni pr1 = new Nasipni("ime", 25.2);
  115. pr1.Print();
  116. pr1.ProdazhnaCena(pr1.Price);
  117. Console.WriteLine(pr1.ProdazhnaCena(pr1.Price));
  118. Nasipni pr2 = new Nasipni("ime", 40.2);
  119. pr2.Print();
  120. pr2.ProdazhnaCena(pr2.Price);
  121. Console.WriteLine(pr2.ProdazhnaCena(pr2.Price));
  122. }
  123. }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement