Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.19 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Магазин_2._0
  4. {
  5. internal class buyer
  6. {
  7. private double money;
  8. private string name;
  9.  
  10. public buyer(string n)
  11. {
  12. this.name = n;
  13. }
  14.  
  15. public void Getvalue()
  16. {
  17. Console.WriteLine("Введите количество денег");
  18. money = Convert.ToDouble(Console.ReadLine());
  19. Console.WriteLine($"насчёту {name} : {Money} рублей");
  20. }
  21.  
  22. public void PrintZavozInfo(magazine magaz)
  23. {
  24. Console.WriteLine(magaz.nazva);
  25. Console.WriteLine(magaz.kolvo);
  26. Console.WriteLine(magaz.price);
  27. }
  28. public double Price
  29. {
  30. get { return Price; }
  31. set { value = Price; }
  32. }
  33. public int Kolvo
  34. {
  35. get { return Kolvo; }
  36. set { value = Kolvo; }
  37. }
  38. public double Buy
  39. {
  40. get { return Buy; }
  41. set { value = Price * Kolvo; }
  42. }
  43. public void pokupka()
  44. {
  45. double sdacha;
  46. if (Money < Price)
  47. {
  48. Console.WriteLine($"У вас недостаточно средств!");
  49. }
  50. else if (Money > Price)
  51. {
  52. sdacha = Money - Buy;
  53. if (sdacha > Buy)
  54. {
  55. Console.WriteLine("Покупка совершена");
  56. Console.WriteLine($"Ваша сдача {sdacha} рублей");
  57. Console.WriteLine();
  58. Console.WriteLine($"Выручка {Buy} рублей");
  59. }
  60. else Console.WriteLine("Не хватает денег");
  61. }
  62. else Console.WriteLine("Не хватает денег");
  63. Console.WriteLine("Выручка = 0");
  64. }
  65.  
  66. public double Money
  67. {
  68. get { return money; }
  69. set { value = money; }
  70. }
  71. }
  72. public abstract class magazine
  73. {
  74. private string name;
  75. private string address;
  76. private string headteacher;
  77. private double TodayMoney;
  78.  
  79. public magazine(string nam, string add, string head)
  80. {
  81. this.name = nam; this.address = add; this.headteacher = head;
  82. }
  83. public string nazva
  84. {
  85. get { return nazva; }
  86. set { value = nazva; }
  87. }
  88. public double price
  89. {
  90. get { return price; }
  91. set { value = price; }
  92. }
  93. public int kolvo
  94. {
  95. get { return kolvo; }
  96. set { value = kolvo; }
  97. }
  98. public string na
  99. {
  100. get { return name; }
  101. set { value = name; }
  102. }
  103.  
  104. public string adr
  105. {
  106. get { return address; }
  107. set { value = address; }
  108. }
  109.  
  110. public string teac
  111. {
  112. get { return headteacher; }
  113. set { value = headteacher; }
  114. }
  115.  
  116. public double TM
  117. {
  118. get { return TodayMoney; }
  119. set { value = TodayMoney; }
  120. }
  121. }
  122.  
  123. internal class Supermarket : magazine
  124. {
  125. public Supermarket(string n, string a, string h) : base(n, a, h)
  126. {
  127. }
  128. public void zavoz()
  129. {
  130. Console.WriteLine("Завоз продуктов");
  131. Console.WriteLine("Название продукта: ");
  132. this.nazva=Console.ReadLine();
  133. Console.WriteLine("Введите цену продукта: ");
  134. this.price=Convert.ToDouble(Console.ReadLine());
  135. Console.WriteLine("Введите количество продуктов: ");
  136. this.kolvo=Convert.ToInt32(Console.ReadLine());
  137. Console.Write($"{nazva} {price} руб. {kolvo} шт.");
  138. Console.WriteLine();
  139. }
  140.  
  141. public void Print()
  142. {
  143. Console.WriteLine($"Наименование магазина: {na}");
  144. Console.WriteLine($"Адрес магазина: {adr}");
  145. Console.WriteLine($"Директор магазина: {teac}");
  146. }
  147. }
  148. public class homemarket : magazine
  149. {
  150. public homemarket(string n, string a, string h) : base(n, a, h)
  151. {
  152. }
  153. public void zavoz()
  154. {
  155. Console.WriteLine("Завоз продуктов");
  156. Console.WriteLine("Название продукта: ");
  157. this.nazva = Console.ReadLine();
  158. Console.WriteLine("Введите цену продукта: ");
  159. this.price = Convert.ToDouble(Console.ReadLine());
  160. Console.WriteLine("Введите количество продуктов: ");
  161. this.kolvo = Convert.ToInt32(Console.ReadLine());
  162. Console.Write($"{nazva} {price} руб. {kolvo} шт.");
  163. Console.WriteLine();
  164. }
  165.  
  166. public void Print()
  167. {
  168. Console.WriteLine($"Наименование магазина: {na}");
  169. Console.WriteLine($"Адрес магазина: {adr}");
  170. Console.WriteLine($"Директор магазина: {teac}");
  171. Console.WriteLine($"Выручка за день: {TM} рублей");
  172. }
  173. }
  174.  
  175. internal class Program
  176. {
  177. private static void Main(string[] args)
  178. {
  179. string stroka;
  180. Console.WriteLine("Выберите магазин Супермаркет Молочный");
  181. stroka = Console.ReadLine();
  182.  
  183. Supermarket sp;
  184. homemarket hm;
  185.  
  186. buyer b = new buyer("Евгений");
  187.  
  188. if (stroka.ToLower() == "супермаркет")
  189. {
  190. string deistvie;
  191. Console.WriteLine("Выберите действия инфо завоз ");
  192. deistvie = Console.ReadLine();
  193. sp = new Supermarket("5", "Серова 15", "Киямов");
  194. if (deistvie.ToLower() == "инфо")
  195. {
  196. sp.Print();
  197. }
  198. else if (deistvie.ToLower() == "завоз")
  199. {
  200. sp.zavoz();
  201. b.PrintZavozInfo(sp);
  202. }
  203. }
  204. else if (stroka.ToLower() == "молочный")
  205. {
  206. string deistvie;
  207. Console.WriteLine("Выберите действия инфо завоз ");
  208. deistvie = Console.ReadLine();
  209. hm = new homemarket("ЗМК", "Восстания 60", "Алтынбаев");
  210. if (deistvie.ToLower() == "инфо")
  211. {
  212. hm.Print();
  213. }
  214. else if (deistvie.ToLower() == "завоз")
  215. {
  216. hm.zavoz();
  217. b.PrintZavozInfo(hm);
  218. }
  219. }
  220. b.Getvalue();
  221. b.pokupka();
  222. Console.ReadKey();
  223. }
  224. }
  225. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement