Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace practice2407
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- Person pers1 = new Person("Dima", 20, PersonBehaviour.Aggressive);
- Person pers2 = new Person("Oleg", 30, PersonBehaviour.Polite);
- Employee pers3 = new Employee("Muzhik", 75, 44000);
- Console.WriteLine(pers3.salary);
- }
- class Person
- {
- public string name;
- public int age;
- public PersonBehaviour behaviour;
- public Person (string name, int age, PersonBehaviour behaviour) {
- this.name = name;
- this.age = age;
- this.behaviour = behaviour;
- }
- public Person(string name, int age)
- {
- this.name = name;
- this.age = age;
- }
- public PersonBehaviour GetBehaviour () {
- return this.behaviour;
- }
- }
- class Employee : Person {
- public int salary;
- public Employee(string name, int age, PersonBehaviour behaviour, int salary) : base(name,age,behaviour)
- {
- this.salary = salary;
- }
- public Employee(string name, int age,int salary) : base(name, age)
- {
- this.salary = salary;
- }
- }
- enum PersonBehaviour
- {
- Aggressive,
- Passive,
- Polite
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement