Adding assignments
This commit is contained in:
22
Figures/Circle.cs
Normal file
22
Figures/Circle.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace OOP.Figures
|
||||
{
|
||||
public class Circle : Shape
|
||||
{
|
||||
public Circle(double radius)
|
||||
{
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public double radius { get; set; }
|
||||
|
||||
public override double GetArea()
|
||||
{
|
||||
return Math.PI * Math.Pow(radius, 2);
|
||||
}
|
||||
|
||||
public override double GetPerimeter()
|
||||
{
|
||||
return 2 * Math.PI * radius;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Figures/Rectangle.cs
Normal file
24
Figures/Rectangle.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace OOP.Figures
|
||||
{
|
||||
public class Rectangle : Shape
|
||||
{
|
||||
public Rectangle(double width, double height)
|
||||
{
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public double height { get; set; }
|
||||
public double width { get; set; }
|
||||
|
||||
public override double GetArea()
|
||||
{
|
||||
return height * width;
|
||||
}
|
||||
|
||||
public override double GetPerimeter()
|
||||
{
|
||||
return (height * 2) + (width * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Figures/Shape.cs
Normal file
8
Figures/Shape.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace OOP.Figures
|
||||
{
|
||||
public abstract class Shape
|
||||
{
|
||||
public abstract double GetArea();
|
||||
public abstract double GetPerimeter();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user