mjc65

prop

May 5th, 2020
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1. class Rectangle
  2. {
  3.     private double length;
  4.     private double width;
  5.  
  6.     public double Length
  7.     {
  8.         get
  9.         {
  10.             return length;
  11.         }
  12.         set
  13.         {
  14.             if ( value > 0.0)
  15.                 length = value;
  16.         }
  17.     }
  18.  
  19.     public double Width
  20.     {
  21.         get
  22.         {
  23.             return width;
  24.         }
  25.         set
  26.         {
  27.             if (value > 0.0 )
  28.                 width = value;
  29.         }
  30.     }
  31.  
  32.     public double GetArea()
  33.     {
  34.         return length * width;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment