Advertisement
khaiwen1111

Practical 2

Jun 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2. namespace Practice
  3. {
  4.     public class Employee
  5.     {
  6.         private string name;
  7.         private string date;
  8.         private decimal salary;
  9.  
  10.         public string Name
  11.         {
  12.             get
  13.             {
  14.                 return name;
  15.             }
  16.         }
  17.         public string Date
  18.         {
  19.             get
  20.             {
  21.                 return date;
  22.             }
  23.         }
  24.         public decimal Salary
  25.         {
  26.             get
  27.             {
  28.                 return salary;
  29.             }
  30.             set
  31.             {
  32.                 salary = value;
  33.             }
  34.         }
  35.  
  36.         public Employee(string theName, string theDate, decimal theSalary)
  37.         {
  38.             name = theName;
  39.             date = theDate;
  40.             Salary = theSalary;
  41.         }
  42.     }
  43.     public class EmployeeTest1
  44.     {
  45.         public static void Main()
  46.         {
  47.             Employee emp1 = new Employee("John", "12/05/18", 2500);
  48.  
  49.             Console.WriteLine("Name is {0} ", emp1.Name);
  50.             Console.WriteLine("Date is {0}", emp1.Date);
  51.             Console.WriteLine("Salary is {0}", emp1.Salary);
  52.  
  53.             emp1.Salary = 2750;
  54.             Console.WriteLine("New Salary is {0}", emp1.Salary);
  55.  
  56.         }
  57.  
  58.        
  59.     }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement