Не мога да си намеря грешката в base
Не мога да разбера защо ми дава грешка на base при квадрат и окръжност и в main ми дава на switch-case грешка според мен идва от base
Main
Console.Write("How many figure want : ");
var a = int.Parse(Console.ReadLine());
ColoredFigure item;
for(int i =0; i < a; i++)
{
string[] parameters = Console.ReadLine().Split(' ').ToArray();
switch(parameters[0])
{
case "Triangle":
item = new Triangle(parameters[1], int.Parse(parameters[2]));
break;
case "Square":
item = new Square(parameters[1], int.Parse(parameters[2]));
break;
default:
item = new Circle(parameters[1], int.Parse(parameters[2]));
break;
}
Console.WriteLine(item.GetName() + ":");
item.Show();
Console.WriteLine("Area : {0:0.00}", Math.Round(item.GetArea(), 2));
Console.WriteLine("Obikolka : {0:0.00}", Math.Round(item.Obikolka(), 2));
Main class
protected int sizea;
protected int sizeb;
protected int h;
public ColoredFigure(int sizea, int sizeb, int h)
{
this.sizea = sizea;
this.sizeb = sizeb;
this.h = h;
}
public void Show()
{
Console.WriteLine("Size a : " + this.sizea);
Console.WriteLine("Size b : " + this.sizeb);
Console.WriteLine("Size h : " + this.h);
}
public abstract string GetName();
public abstract double GetArea();
public abstract double Obikolka();
Triagalnik
public Triangle(int sizea,int sizeb,int h)
: base(sizea, sizeb,h)
{
}
public override string GetName()
{
return "Triangle";
}
public override double GetArea()
{
return (Math.Pow(sizea, 2) * Math.Sqrt(3)) / 2;
}
public override double Obikolka()
{
return (sizea * h) / 2;
}
Kvadrat
public Square(int sizea)
: base(sizea)
{
}
public override string GetName()
{
return "Square";
}
public override double GetArea()
{
return (Math.Pow(sizea, 2));
}
public override double Obikolka()
{
return 4*sizea;
}
okrajnost
public Circle( int sizea)
: base(sizea)
{
}
public override string GetName()
{
return "Circle";
}
public override double GetArea()
{
return (Math.PI*Math.Pow(sizea, 2));
}
public override double Obikolka()
{
return 2 * (Math.PI) * sizea;
}