Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace Exercise1
  6. {
  7.     public abstract class Shape
  8.     {
  9.         private int color;
  10.  
  11.         public Colors Color
  12.         {
  13.             get
  14.             {
  15.                 Colors returnValue = Colors.NONE;
  16.  
  17.                 switch (color)
  18.                 {
  19.                     case 0x00FF0000:
  20.                         returnValue = Colors.RED;
  21.                         break;
  22.                     case 0x0000FF00:
  23.                         returnValue = Colors.GREEN;
  24.                         break;
  25.                     case 0x000000FF:
  26.                         returnValue = Colors.BLUE;
  27.                         break;
  28.                 }
  29.  
  30.                 return returnValue;
  31.             }
  32.             set
  33.             {
  34.                 switch (value)
  35.                 {
  36.                     case Colors.RED:
  37.                         this.color = 0x00FF0000;
  38.                         break;
  39.                     case Colors.GREEN:
  40.                         this.color = 0x0000FF00;
  41.                         break;
  42.                     case Colors.BLUE:
  43.                         this.color = 0x000000FF;
  44.                         break;
  45.                 }
  46.             }
  47.         }
  48.  
  49.         public enum Colors
  50.         {
  51.             NONE = 0,
  52.             RED = 1,
  53.             GREEN = 2,
  54.             BLUE = 3
  55.         }
  56.  
  57.         public abstract double GetArea();
  58.  
  59.         public abstract double GetPerimeter();
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement