Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace OOP_Principles2
  8. {
  9.     class Shapes
  10.     {
  11.         public abstract class Shape
  12.         {
  13.             private double width;
  14.             private double height;
  15.             private double surface;
  16.  
  17.             public Shape(double width, double height)
  18.             {
  19.                 this.width = width;
  20.                 this.height = height;
  21.  
  22.             }
  23.  
  24.             public double Width
  25.             {
  26.                 get { return this.width; }
  27.  
  28.                 private set
  29.                 {
  30.                     if (value <= 0)
  31.                     {
  32.                         throw new ArgumentException("Width cant be less or equal of 0");
  33.                     }
  34.                     this.width = value;
  35.                 }
  36.  
  37.  
  38.             }
  39.  
  40.             public double Height
  41.             {
  42.                 get { return this.height; }
  43.                 private set{
  44.  
  45.                
  46.                 if(value <= 0)
  47.             {
  48.                 throw new ArgumentException("Height cant be less or equal of 0");
  49.             }
  50.             this.height = value;
  51.             }
  52.  
  53.  
  54.             }
  55.  
  56.             public double Surface
  57.             {
  58.                 get { return this.surface; }
  59.  
  60.                 protected set
  61.                 {
  62.                     this.surface = value;
  63.                 }
  64.             }
  65.  
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement