Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CodeKata
- {
- public abstract class Shape
- {
- public double Side { get; set; }
- public double Radius { get; set; }
- public double Base { get; set; }
- public double Height { get; set; }
- public double Width { get; set; }
- public abstract double Size ();
- }
- public class Square : Shape
- {
- public override double Size() => Side * Side;
- public Square(double side)
- {
- Side = side;
- Size();
- }
- }
- public class Rectangle : Shape
- {
- public override double Size() => Width * Height;
- public Rectangle(double width, double height)
- {
- Width = width;
- Height = height;
- Size();
- }
- }
- public class Triangle : Shape
- {
- public override double Size() => (Base * Height) / 2;
- public Triangle(double triangleBase, double height)
- {
- Base = triangleBase;
- Height = height;
- Size();
- }
- }
- public class Circle : Shape
- {
- public override double Size()
- {
- const double pi = System.Math.PI;
- return Radius * pi;
- }
- public Circle(double radius)
- {
- Radius = radius;
- Size();
- }
- }
- public class CustomShape : Shape
- {
- public override double Size()
- {
- return Side;
- }
- public CustomShape(double side)
- {
- Side = side;
- Size();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement