-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmployee.cs
109 lines (97 loc) · 3.27 KB
/
Employee.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BethanyPieShopHRM
{
public class Employee
{
private string firstName;
private string lastName;
private string email;
private int numberOfHoursWorked;
private double wage;
private double hourlyRate;
private DateTime birthDay;
private EmployeeType employeeType;
public string FirstName
{
get{return firstName;} set { firstName = value;}
}
public string LastName
{
get {return lastName; } set { lastName = value;}
}
public string Email
{
get { return email; } set { email = value; }
}
public int NumberOfHoursWorked
{
get { return numberOfHoursWorked;} set { numberOfHoursWorked = value; }
}
public double Wage
{
get { return wage; }
set {
if (wage < 0)
wage = 0;
else
wage = value;
}
}
public double HourlyRate
{
get { return hourlyRate; } set { hourlyRate = value; }
}
public DateTime BirthDay
{
get { return birthDay; }
set { birthDay = value; }
}
public EmployeeType EmployeeType
{
get { return employeeType; }
set { employeeType = value; }
}
//creating constructor (Constructors are special types of methods used to create and initialize objects)
public Employee(string first, string last, string em, DateTime bday, EmployeeType empType, double rate)
{
FirstName = first;
LastName = last;
Email = em;
BirthDay = bday;
EmployeeType = empType;
HourlyRate = rate;
}
public Employee(string first, string last, string em, DateTime bday, EmployeeType empType) : this (first, last, em, bday, empType, 0)
{
// call the upper constructor (contains 6 parameters) from this constructor (contains 5 parameters) using the key 'this'
// this constructor invokes the one above, passing the 5 parameters from above (with values that are in the variables) and the sixth parameter passes value 0
}
//creating methods
public void PerfomWork()
{
numberOfHoursWorked++;
Console.WriteLine($"{FirstName} {LastName} is now working!");
}
public void StopWorking()
{
Console.WriteLine($"{FirstName} {LastName} has stopped working!");
}
public double ReceiveWage()
{
Wage = NumberOfHoursWorked * HourlyRate;
Console.WriteLine($"The wage for {NumberOfHoursWorked} hours of work is {Wage}");
NumberOfHoursWorked = 0;
return wage;
}
public void DisplayEmployeeDetais()
{
Console.WriteLine($"\nFirst Name: {FirstName}\nLast Name: {LastName}" +
$"\nEmail: {Email}\nBirthday: {BirthDay.ToShortDateString()}" +
$"\nEmployee type: {EmployeeType}\n");
}
}
}