Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace prac2
  8. {
  9. public abstract class Client
  10. {
  11.  
  12. public abstract void DisplayInfo();
  13.  
  14. public abstract bool DateChecker(DateTime date);
  15.  
  16. }
  17.  
  18. public class Investor : Client
  19. {
  20. public string LastName { get; set; }
  21. public DateTime DepositOpenDate { get; set; }
  22. public decimal DepositAmount { get; set; }
  23. public double DepositInterest { get; set; }
  24.  
  25. public Investor(string lastName, DateTime depositDate, decimal depositAmount, double depositInteres)
  26. {
  27. LastName = lastName;
  28. DepositOpenDate = depositDate;
  29. DepositAmount = depositAmount;
  30. DepositInterest = depositInteres;
  31. }
  32.  
  33. public override void DisplayInfo()
  34. {
  35. Console.WriteLine("Фамилия вкладчика: {0}", LastName);
  36. Console.WriteLine("Дата открытия вклада: {0}", DepositOpenDate.ToShortDateString());
  37. Console.WriteLine("Размер вклада: {0}", DepositAmount);
  38. Console.WriteLine("Процент по вкладу: {0}", DepositInterest);
  39. }
  40.  
  41. public override bool DateChecker(DateTime date)
  42. {
  43. if (DepositOpenDate == date)
  44. return true;
  45. return false;
  46. }
  47. }
  48.  
  49. public class Creditor : Client
  50. {
  51. public string LastName { get; set; }
  52. public DateTime LoanIssuanceDate { get; set; }
  53. public decimal LoanAmount { get; set; }
  54. public double CreditInterest { get; set; }
  55. public decimal BalanceOfDebt { get; set; }
  56.  
  57.  
  58. public Creditor(string lastName, DateTime loanIssuanceDate, decimal loanAmount, double creditInterest,
  59. decimal balanceOfDebt)
  60. {
  61. LastName = lastName;
  62. LoanIssuanceDate = loanIssuanceDate;
  63. LoanAmount = loanAmount;
  64. CreditInterest = creditInterest;
  65. BalanceOfDebt = balanceOfDebt;
  66. }
  67.  
  68. public override void DisplayInfo()
  69. {
  70. Console.WriteLine("Фамилия вкладчика: {0}", LastName);
  71. Console.WriteLine("Дата выдачи кредита: {0}", LoanIssuanceDate.ToShortDateString());
  72. Console.WriteLine("Размер кредита: {0}", LoanAmount);
  73. Console.WriteLine("Процент по кредиту: {0}", CreditInterest);
  74. Console.WriteLine("Остаток долга: {0}", BalanceOfDebt);
  75. }
  76.  
  77. public override bool DateChecker(DateTime date)
  78. {
  79. if (LoanIssuanceDate == date)
  80. return true;
  81. return false;
  82. }
  83. }
  84.  
  85. public class Organization : Client
  86. {
  87. public string Name { get; set; }
  88. public DateTime AccountOpenDate { get; set; }
  89. public int AccountNumber { get; set; }
  90. public decimal AmountOnAccount { get; set; }
  91.  
  92. public Organization(string name, DateTime accountOpenDate, int accountNumber, decimal amountOfAccount)
  93. {
  94. Name = name;
  95. AccountOpenDate = accountOpenDate;
  96. AccountNumber = accountNumber;
  97. AmountOnAccount = amountOfAccount;
  98. }
  99.  
  100. public override void DisplayInfo()
  101. {
  102. Console.WriteLine("Название организации: {0}", Name);
  103. Console.WriteLine("Дата открытия счета: {0}", AccountOpenDate.ToShortDateString());
  104. Console.WriteLine("Номер счета: {0}", AccountNumber);
  105. Console.WriteLine("Сумма на счету: {0}", AmountOnAccount);
  106. }
  107. public override bool DateChecker(DateTime date)
  108. {
  109. if (AccountOpenDate == date)
  110. return true;
  111. return false;
  112. }
  113.  
  114. }
  115.  
  116. class Program
  117. {
  118.  
  119. static void Main(string[] args)
  120. {
  121. Client[] clientDataBase = new Client[]
  122. {
  123. new Investor("Sokolov", new DateTime(2019,5,7), 250178.597m, 20.15),
  124. new Investor("Petrov", DateTime.Now, 12178.867m, 18.75),
  125. new Creditor("Clerk", new DateTime(2015, 8, 9), 12178.867m, 18.75, 578.89m),
  126. new Creditor("Grant", new DateTime(2013, 7, 19), 12178.867m, 18.75, 578.89m),
  127. new Organization("Organization №1", new DateTime(2013,2,18), 123456785, 7894623.7834m),
  128. new Organization("Organization №2", new DateTime(2014,3,8), 456456785, 7894623.7834m)
  129. };
  130.  
  131. foreach (Client client in clientDataBase)
  132. {
  133. client.DisplayInfo();
  134. Console.WriteLine();
  135. }
  136.  
  137. Console.WriteLine();
  138.  
  139. DateTime askDate = new DateTime(2015, 8, 9);
  140. int foundClients = 0;
  141.  
  142. foreach (Client client in clientDataBase)
  143. {
  144. if (client.DateChecker(askDate))
  145. {
  146. client.DisplayInfo();
  147. foundClients++;
  148. Console.WriteLine();
  149. }
  150. }
  151. if (foundClients == 0)
  152. {
  153. Console.WriteLine("Клиенты по данной дате не найдены");
  154. }
  155. Console.ReadLine();
  156. }
  157. }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement