Advertisement
wingman007

OOPClassesObjectsProgramPart2

Mar 16th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 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 World1b
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Person stoyan = new Person(); // "Stoyan", 52
  14.             // 1. fields
  15.             // stoyan.name = "Stoyan";
  16.             // stoyan.age = 52;
  17.             // Console.WriteLine("My name is {0}, I am {1} years old!", stoyan.name, stoyan.age);
  18.  
  19.             // 2. methods getter and setter
  20.             // stoyan.SetName("Stoyan");
  21.             // stoyan.SetAge(52);
  22.             // Console.WriteLine("My name is {0}, I am {1} years old!", stoyan.GetName(), stoyan.GetAge());
  23.  
  24.             // 3. properties
  25.             // stoyan.Name = "Stoyan";
  26.             // stoyan.Age = 52;
  27.             // Console.WriteLine("My name is {0}, I am {1} years old!", stoyan.Name, stoyan.Age);
  28.  
  29.             stoyan.IntroduceYourSelf();
  30.  
  31.  
  32.             Person vasko = new Person("Vasko", 18, 123.23, "Stoyan", "Ivan");
  33.             // 1. fiealds
  34.             // vasko.name = "Vasko";
  35.             // vasko.age = 18;
  36.             // Console.WriteLine("My name is {0}, I am {1} years old!", vasko.name, vasko.age);
  37.             // Console.WriteLine("My name is {0}, I am {1} years old!", vasko.Name, vasko.Age);
  38.             vasko.IntroduceYourSelf();
  39.             Console.WriteLine("Friend 0 = {0}", vasko[0]);
  40.  
  41.             Elevator elevator1 = new Elevator(17);
  42.             elevator1.GoUp(10);
  43.             Console.WriteLine("The elevator1 is on floor {0}", elevator1.GetCurrentFloor());
  44.  
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement