Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Shape
- {
- }
- class Rectangle : Shape
- {
- public float width;
- public float height;
- }
- class Circle : Shape
- {
- public float radius;
- }
- class ShapeTools
- {
- public float Area(Shape shape)
- {
- if(Shape is Rectangle rect)return rect.width * rect.height;
- if(Shape is Circle circle)return circle * circle * Mathf.PI;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement