Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace prac2
- {
- public abstract class Client
- {
- public abstract void DisplayInfo();
- public abstract bool DateChecker(DateTime date);
- }
- public class Investor : Client
- {
- public string LastName { get; set; }
- public DateTime DepositOpenDate { get; set; }
- public decimal DepositAmount { get; set; }
- public double DepositInterest { get; set; }
- public Investor(string lastName, DateTime depositDate, decimal depositAmount, double depositInteres)
- {
- LastName = lastName;
- DepositOpenDate = depositDate;
- DepositAmount = depositAmount;
- DepositInterest = depositInteres;
- }
- public override void DisplayInfo()
- {
- Console.WriteLine("Фамилия вкладчика: {0}", LastName);
- Console.WriteLine("Дата открытия вклада: {0}", DepositOpenDate.ToShortDateString());
- Console.WriteLine("Размер вклада: {0}", DepositAmount);
- Console.WriteLine("Процент по вкладу: {0}", DepositInterest);
- }
- public override bool DateChecker(DateTime date)
- {
- if (DepositOpenDate == date)
- return true;
- return false;
- }
- }
- public class Creditor : Client
- {
- public string LastName { get; set; }
- public DateTime LoanIssuanceDate { get; set; }
- public decimal LoanAmount { get; set; }
- public double CreditInterest { get; set; }
- public decimal BalanceOfDebt { get; set; }
- public Creditor(string lastName, DateTime loanIssuanceDate, decimal loanAmount, double creditInterest,
- decimal balanceOfDebt)
- {
- LastName = lastName;
- LoanIssuanceDate = loanIssuanceDate;
- LoanAmount = loanAmount;
- CreditInterest = creditInterest;
- BalanceOfDebt = balanceOfDebt;
- }
- public override void DisplayInfo()
- {
- Console.WriteLine("Фамилия вкладчика: {0}", LastName);
- Console.WriteLine("Дата выдачи кредита: {0}", LoanIssuanceDate.ToShortDateString());
- Console.WriteLine("Размер кредита: {0}", LoanAmount);
- Console.WriteLine("Процент по кредиту: {0}", CreditInterest);
- Console.WriteLine("Остаток долга: {0}", BalanceOfDebt);
- }
- public override bool DateChecker(DateTime date)
- {
- if (LoanIssuanceDate == date)
- return true;
- return false;
- }
- }
- public class Organization : Client
- {
- public string Name { get; set; }
- public DateTime AccountOpenDate { get; set; }
- public int AccountNumber { get; set; }
- public decimal AmountOnAccount { get; set; }
- public Organization(string name, DateTime accountOpenDate, int accountNumber, decimal amountOfAccount)
- {
- Name = name;
- AccountOpenDate = accountOpenDate;
- AccountNumber = accountNumber;
- AmountOnAccount = amountOfAccount;
- }
- public override void DisplayInfo()
- {
- Console.WriteLine("Название организации: {0}", Name);
- Console.WriteLine("Дата открытия счета: {0}", AccountOpenDate.ToShortDateString());
- Console.WriteLine("Номер счета: {0}", AccountNumber);
- Console.WriteLine("Сумма на счету: {0}", AmountOnAccount);
- }
- public override bool DateChecker(DateTime date)
- {
- if (AccountOpenDate == date)
- return true;
- return false;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Client[] clientDataBase = new Client[]
- {
- new Investor("Sokolov", new DateTime(2019,5,7), 250178.597m, 20.15),
- new Investor("Petrov", DateTime.Now, 12178.867m, 18.75),
- new Creditor("Clerk", new DateTime(2015, 8, 9), 12178.867m, 18.75, 578.89m),
- new Creditor("Grant", new DateTime(2013, 7, 19), 12178.867m, 18.75, 578.89m),
- new Organization("Organization №1", new DateTime(2013,2,18), 123456785, 7894623.7834m),
- new Organization("Organization №2", new DateTime(2014,3,8), 456456785, 7894623.7834m)
- };
- foreach (Client client in clientDataBase)
- {
- client.DisplayInfo();
- Console.WriteLine();
- }
- Console.WriteLine();
- DateTime askDate = new DateTime(2015, 8, 9);
- int foundClients = 0;
- foreach (Client client in clientDataBase)
- {
- if (client.DateChecker(askDate))
- {
- client.DisplayInfo();
- foundClients++;
- Console.WriteLine();
- }
- }
- if (foundClients == 0)
- {
- Console.WriteLine("Клиенты по данной дате не найдены");
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement