Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace practice2407
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             Person pers1 = new Person("Dima", 20, PersonBehaviour.Aggressive);
  10.             Person pers2 = new Person("Oleg", 30, PersonBehaviour.Polite);
  11.             Employee pers3 = new Employee("Muzhik", 75, 44000);
  12.             Console.WriteLine(pers3.salary);
  13.  
  14.         }
  15.  
  16.         class Person
  17.         {
  18.             public string name;
  19.             public int age;
  20.             public PersonBehaviour behaviour;
  21.  
  22.             public Person (string name, int age, PersonBehaviour behaviour) {
  23.                 this.name = name;
  24.                 this.age = age;
  25.                 this.behaviour = behaviour;
  26.             }
  27.  
  28.             public Person(string name, int age)
  29.             {
  30.                 this.name = name;
  31.                 this.age = age;
  32.             }
  33.  
  34.             public PersonBehaviour GetBehaviour () {
  35.                 return this.behaviour;
  36.             }
  37.         }
  38.  
  39.         class Employee : Person {
  40.             public int salary;
  41.  
  42.             public Employee(string name, int age, PersonBehaviour behaviour, int salary) : base(name,age,behaviour)
  43.             {
  44.                 this.salary = salary;
  45.             }
  46.             public Employee(string name, int age,int salary) : base(name, age)
  47.             {
  48.                 this.salary = salary;
  49.             }
  50.         }
  51.  
  52.         enum PersonBehaviour
  53.         {
  54.             Aggressive,
  55.             Passive,
  56.             Polite
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement