Advertisement
callumbinner22

Shape Class

Apr 6th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 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 OBJECTORIENTATEDCODE
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Shape sqaure = new Shape()
  14.             {
  15.                 numberofsides = 4,
  16.                 sidelength = 2,
  17.                 regular = true,
  18.              
  19.             };
  20.  
  21.             sqaure.getperimeter();
  22.             sqaure.getarea();
  23.  
  24.         }
  25.     }
  26.  
  27.  
  28.  
  29.  
  30.     class Shape
  31.     {
  32.  
  33.  
  34.  
  35.  
  36.        
  37.        
  38.         public int numberofsides;
  39.         public int sidelength;
  40.         public bool regular;
  41.  
  42.         public void getperimeter()
  43.         {
  44.            // Console.WriteLine("Number of sides " + this.numberofsides);
  45.           //  Console.WriteLine("Side length " + this.sidelength);
  46.           //  Console.WriteLine("Regular? " + this.regular);
  47.  
  48.             Console.WriteLine(this.sidelength * this.numberofsides);
  49.         }
  50.  
  51.         public void getarea()
  52.         {
  53.             Console.WriteLine(this.sidelength * 2);
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement