Advertisement
Guest User

Untitled

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