Advertisement
Guest User

Untitled

a guest
May 25th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 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 EmployeeApp {
  8.     partial class Employee {
  9.         private string empName;
  10.         private int empID;
  11.         private float currPay;
  12.         private int empAge;
  13.         private string empSSN;
  14.  
  15.         public Employee() { }
  16.  
  17.         public Employee(string name, int id, float pay, string ssn)
  18.             : this (name, 0, id, pay, ssn) { }
  19.  
  20.         public Employee(string name, int age, int id, float pay, string ssn) {
  21.             Name = name;
  22.             ID = id;
  23.             Age = age;
  24.             Pay = pay;
  25.             empSSN = ssn;
  26.         }
  27.  
  28.         public void GiveBonus(float amount) {
  29.             currPay += amount;
  30.         }
  31.  
  32.         public void DisplayStats() {
  33.             Console.WriteLine ($"Name: {empName}");
  34.             Console.WriteLine ($"ID: {empID}");
  35.             Console.WriteLine ($"Age: {empAge}");
  36.             Console.WriteLine ($"Pay: {currPay}");
  37.             Console.WriteLine ($"SSN: {empSSN}");
  38.         }
  39.  
  40.         public string Name {
  41.             get { return empName; }
  42.             set {
  43.                 if (value.Length > 15)
  44.                     Console.WriteLine ("Error! Name must be less than 15 characters!");
  45.                 else
  46.                     empName = value;
  47.             }
  48.         }
  49.  
  50.         public int Age {
  51.  
  52.             get { return empAge; }
  53.             set { empAge = value; }
  54.         }
  55.  
  56.         public int ID {
  57.             get { return empID; }
  58.             set { empID = value; }
  59.         }
  60.  
  61.         public float Pay {
  62.             get { return currPay; }
  63.             set { currPay = value; }
  64.         }
  65.  
  66.         public string SocialSecurityNumber {
  67.             get { return empSSN; }
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement