Исправить ошибки в коде - C# (179149)
Формулировка задачи:
class Tel
{
protected string marka;
protected int funk;
string _marka
{
get { return marka; }
set { marka = value; }
}
public int _funk
{
get { return funk; }
set { funk = value; }
}
virtual public double Fondcost()
{
return 40 * Math.Log(funk);
}
public Tel()
{
marka = "";
funk = 0;
}
public Tel(string _marka, int _funk)
{
marka = _marka;
funk = _funk;
}
public void Print()
{
Console.WriteLine("marka: " + _marka);
Console.WriteLine("funk " + funk);
Console.WriteLine("wdadw {0} ", Fondcost());
}
}
class Sotov : Tel
{
string model;
int god;
public Sotov()
{
model = "";
god = 0;
}
public int _god
{
get { return god; }
set { value = god; }
}
string _model
{
get { return model; }
set { model = value; }
}
public Sotov(string _model, int _god, int _funk, string _marka): base (_marka,_funk)
{
model = _model;
god = _god;
}
override public double Fondcost()
{
if (DateTime.Today.Year - god >= 1)
return base.Fondcost() / 0.20 + base.Fondcost();
if (DateTime.Today.Year - god >= 3)
return (base.Fondcost() / 0.60) - base.Fondcost();
else return base.Fondcost();
}
public void Show()
{
base.Print();
Console.WriteLine("model: " + model);
Console.WriteLine("god " + god);
Console.WriteLine("стоимость {0}", Fondcost());
}
}
class Stas : Tel
{
bool mob;
public Stas()
{
if (mob == 1)
base.Fondcost() * 5.7;
return true;
else
base.Fondcost() /3.2;
return false;
}
public Stas( bool Mob,int _funk, string _marka): base(_marka, _funk)
{
this.mob = Mob;
}
override public double Fondcost()
{
}
public void Show()
{
Console.WriteLine("funk " + funk );
Console.WriteLine("cost " + Fondcost());
}
class Prog
{
static void Main(string[] args)
{
Console.WriteLine("Введите Марку и кол функций:");
Tel a = new Tel((Console.ReadLine()), Convert.ToInt32(Console.ReadLine()));
a.Print();
a.Fondcost();
Console.WriteLine("Введите Модель сотовый телефон и год и кол функций:");
Sotov w = new Sotov(Console.ReadLine(),Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()));
w.Show();
w.Fondcost();
Console.WriteLine("если у вас перенасной нажмите y если нет n и функци");
Stas e = new Stas(Console.ReadLine(), Convert.ToInt32(Console.ReadLine()));
e.Show();
Console.ReadKey();
}
}
}
}Решение задачи: «Исправить ошибки в коде»
textual
Листинг программы
string x = Console.ReadLine();
int y = 0;
try
{
y = int.Parse(Console.ReadLine());
}
catch (ArgumentException)
{
Console.WriteLine("Строка неверная!");
// Something todo when error occured...
}
Tel a = new Tel(x,y);
a.Print();