Advertisement
Eresor

Untitled

Oct 8th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1. class Shape
  2. {
  3.  
  4. }
  5.  
  6. class Rectangle : Shape
  7. {
  8.     public float width;
  9.     public float height;
  10. }
  11.  
  12. class Circle : Shape
  13. {
  14.     public float radius;
  15. }
  16.  
  17. class ShapeTools
  18. {
  19.     public float Area(Shape shape)
  20.     {
  21.         if(Shape is Rectangle rect)return rect.width * rect.height;
  22.         if(Shape is Circle circle)return circle * circle * Mathf.PI;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement