Подскажите что не правильно моей архитектуре классов, препод говорит что не правильная архитектура классов, чего не правильного-то ?)`
using System;
using System.Collections.Generic;
using System.Threading;
namespace ConsoleApplication97
{
abstract class Securities
{
string fullName;
string shortName;
string issuerName;
DateTime dateOfEmission;
double volume;
public Securities()
{
}
public Securities(string f, string sh, string iss, DateTime de, double v)
{
FullName = f;
ShortName = sh;
IssuerName = iss;
DateOfEmission = de;
Volume = v;
}
protected string FullName
{
get
{
return fullName;
}
set
{
fullName = value;
}
}
protected string ShortName
{
get
{
return shortName;
}
set
{
shortName = value;
}
}
protected string IssuerName
{
get
{
return issuerName;
}
set
{
issuerName = value;
}
}
protected DateTime DateOfEmission
{
get
{
return dateOfEmission;
}
set
{
dateOfEmission = value;
}
}
protected double Volume
{
get
{
return volume;
}
set
{
volume = value;
}
}
public abstract void ChangeCurrentPrice(double cp);
public abstract string ToStringFields();
}
class Share : Securities
{
string typeShare;
double currentPrice;
double balanceOfCost;
double lotSize;
public Share(string f, string sh, string iss, DateTime de, double v, string tysh, double cp, double bc, double ls) : base(f, sh, iss, de, v)
{
TypeShare = tysh;
CurrentPrice = cp;
BalanceOfCost = bc;
LotSize = ls;
}
public Share()
{
}
public string TypeShare
{
get
{
return typeShare;
}
set
{
typeShare = value;
}
}
public double CurrentPrice
{
get
{
return currentPrice;
}
set
{
currentPrice = value;
}
}
public double BalanceOfCost
{
get
{
return balanceOfCost;
}
set
{
balanceOfCost = value;
}
}
public double LotSize
{
get
{
return lotSize;
}
set
{
lotSize = value;
}
}
public override void ChangeCurrentPrice(double cp)
{
currentPrice = cp;
}
public override string ToStringFields()
{
return FullName + "\n" + ShortName + "\n" + IssuerName + "\n" + DateOfEmission + "\n" + Volume + "\n" +
TypeShare + "\n" + CurrentPrice + "\n" + BalanceOfCost + "\n" + LotSize + "\n-----------------------------";
}
public double CalcAmountOfDevidends(bool t)
{
if (typeShare == "Обычная")
{
return balanceOfCost * 0.05;
}
else
{
if (t)
{
return balanceOfCost * 0.05;
}
else
{
return 0;
}
}
}
}
class Bond : Securities
{
string typeBond;
double ratedCost;
double currentPrice;
DateTime datePerformance;
double percentCoupon;
public Bond(string f, string sh, string iss, DateTime de, double v, string tyB, double rC, double cp, DateTime dP, double pc) : base(f, sh, iss, de, v)
{
TypeBond = tyB;
RatedCost = rC;
CurrentPrice = cp;
DatePerformance = dP;
PercentCoupon = pc;
}
public Bond()
{
}
public string TypeBond
{
get
{
return typeBond;
}
set
{
typeBond = value;
}
}
public double RatedCost
{
get
{
return ratedCost;
}
set
{
ratedCost = value;
}
}
public double CurrentPrice
{
get
{
return currentPrice;
}
set
{
currentPrice = value;
}
}
public DateTime DatePerformance
{
get
{
return datePerformance;
}
set
{
datePerformance = value;
}
}
public double PercentCoupon
{
get
{
return percentCoupon;
}
set
{
percentCoupon = value;
}
}
public override void ChangeCurrentPrice(double cp)
{
CurrentPrice = cp;
}
public override string ToStringFields()
{
return FullName + "\n" + ShortName + "\n" + IssuerName + "\n" + DatePerformance + "\n" + Volume + "\n" +
TypeBond + "\n" + RatedCost + "\n" + CurrentPrice + "\n" + DatePerformance + "\n" + PercentCoupon + "\n-----------------------------";
}
public double CalcSumCoupon()
{
if (TypeBond == "Купон")
{
05.06.16
return PercentCoupon * RatedCost;
}
else
{
return 0;
}
}
}
class Program
{
static void Main(string[] args)
{
List<Securities> list = new List<Securities>();
list.Add(new Bond("ПУБЛИЧНОЕ АКЦИОНЕРНОЕ ОБЩЕСТВО «ГОРНО - МЕТАЛЛУРГИЧЕСКАЯ КОМПАНИЯ» «НОРИЛЬСКИЙ НИКЕЛЬ»",
"ПАО ГОРНО - МЕТАЛЛУРГИЧЕСКАЯ КОМПАНИЯ НОРИЛЬСКИЙ НИКЕЛЬ",
"ОАО «Российское акционерное общество «Норильский никель», ОАО «РАО «Норильский никель»",
new DateTime(2016, 10, 1), 3500, "Дисконтная", 150, 45, new DateTime(2016, 11, 1), 0.15));
list.Add(new Share("Ростелеком(ПАО) АО", "Ростел-AO", "RTKM", new DateTime(2013, 5, 6), 6000, "Обычная", 47,
45, 48));
list.Add(new Share("акц.пр. ОАО АК Транснефть", "Транснф АП", "TRNFP", new DateTime(2013, 5, 6), 6500, "Привилегированная", 45, 36, 46));
list.Add(new Bond("АКЦИОНЕРНОЕ ОБЩЕСТВО «АЛЬФА-БАНК»", "АО «АЛЬФА-БАНК»", "Альфа-Банк",
new DateTime(2015, 1, 1), 5000, "Купонная", 200, 15, new DateTime(2015, 2, 1), 0.11));
list.Insert(0,
new Bond("Публичное акционерное общество «Сбербанк России»", "АО «АЛЬФА-БАНК»", "ПАО Сбербанк",
new DateTime(2014, 1, 1), 4000, "Купонная", 400, 25, new DateTime(2014, 3, 1), 0.08)); //доб.в начало списка
list.RemoveAt(1); //удаление из списка 2 элемента
while (true)
{
for (int i = 0; i < list.Count; i++)
{
if (new Random().Next() % 2 == 1)
{
if (typeof(Bond) == list[i].GetType())
{
list[i].ChangeCurrentPrice(((Bond)(list[i])).CurrentPrice + new Random().NextDouble());
}
else
{
list[i].ChangeCurrentPrice(((Share)(list[i])).CurrentPrice + new Random().NextDouble());
}
}
}
Thread.Sleep(new Random().Next(1000, 10000));
foreach (var sec in list)
{
Console.WriteLine(sec.ToStringFields());
}
}
Console.ReadKey();
}
}
}