Нужно реализовать наследование классом Squre методов класса Rectangle - C#
Формулировка задачи:
нужно реализовать наследование классом Squre методов класса Rectangle
class Square
{
private int _xPos;
private int _yPos;
private int _height;
private int _weight;
private static int _angle=90;
private double _side;
private static string _className="Square";
public Square (int x1, int y1, int x4, int y3)
{
_xPos=x1;
_yPos=y1;
_height=y3-y1;
_weight=x4-x1;
_side=Math.Sqrt(((_height*_height)+(_weight*_weight))/2);
}
public double GetSquareSide()
{
return _side;
}
public double GetPerimeter()
{
double perimeter = 4 * _side;
return perimeter;
}
public double GetSquareHeight()
{
return _height;
}
public double GetSquareWeight()
{
return _weight;
}
public double GetXPos()
{
double xpos = _xPos;
return xpos;
}
public double GetYPos()
{
double ypos = _yPos;
return ypos;
}
public double GetSquare()
{
double square = (_height * _weight)/2;
return square;
}
public double GetSquareAngle()
{
double angle=_angle;
return angle;
}
public void SetSquarePosition(int xPos, int yPos)
{
_xPos=xPos;
_yPos=yPos;
}
public static string GetClassName()
{
return _className;
}
public void SetClassName(string classname)
{
_className=classname;
}
}class Rectangle
{
public int _xPos;
public int _yPos;
public int _height;
public int _weight;
public static int _angle=90;
public static string _className="Rectangle";
public Rectangle (int x1, int y1, int x2, int y2)
{
_xPos=x1;
_yPos=y1;
_height=y2-y1;
_weight=x2-x1;
}
public double GetHeight()
{
return _height;
}
public double GetWeight()
{
return _weight;
}
public double GetPerimeter()
{
double perimeter = (_height + _weight)*2;
return perimeter;
}
public double GetXPos()
{
double xpos = _xPos;
return xpos;
}
public double GetYPos()
{
double ypos = _yPos;
return ypos;
}
public double GetSquare()
{
double square = _height * _weight;
return square;
}
public double GetRectangleAngle()
{
double angle=_angle;
return angle;
}
public void SetRectanglePosition(int xPos, int yPos)
{
_xPos=xPos;
_yPos=yPos;
}
public static string GetClassName()
{
return _className;
}
public void SetClassName(string classname)
{
_className=classname;
}
}Решение задачи: «Нужно реализовать наследование классом Squre методов класса Rectangle»
textual
Листинг программы
class Square : Rectangle
{
// Реализация Square
}