Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 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 BasicCsharp
  8. {
  9.     class Person
  10.     {
  11.         public string fName;
  12.         public string lName;
  13.         public int age;
  14.         public string origin;
  15.  
  16.         public Person(string fName, string lName, int age, string origin)
  17.         {
  18.             this.fName = fName;
  19.             this.lName = lName;
  20.             this.age = age;
  21.             this.origin = origin;
  22.         }
  23.  
  24.         public void showBio()
  25.         {
  26.             Console.WriteLine(fName + " " + lName + "\nAge: " + age + "\nOrigin: " + origin);
  27.         }
  28.     };
  29.  
  30.     class Employee : Person
  31.     {
  32.         public string fName;
  33.         public string lName;
  34.         public int age;
  35.         public string origin;
  36.         public string department;
  37.         public double salary;
  38.  
  39.         public Employee(string fName,string lName, int age, string origin, string department,double salary)
  40.         {
  41.             this.department = department;
  42.             this.salary = salary;
  43.         }
  44.  
  45.         public void showBio()
  46.         {
  47.             Console.WriteLine("Department: " + department + "\nSalary: " + salary);
  48.         }
  49.     }
  50.     class Program
  51.     {
  52.         static void Main(string[] args)
  53.         {
  54.             Person P1 = new Person("John","Doe",25,"None");
  55.             P1.showBio();
  56.             Employee E1 = new Employee("Abc","Def",40,"Earth","Basics",500.0);
  57.             E1.showBio();
  58.  
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement