diff --git a/Employees/Employee.cs b/Employees/Employee.cs
index a320d4e..1f861ee 100644
--- a/Employees/Employee.cs
+++ b/Employees/Employee.cs
@@ -15,10 +15,9 @@ public abstract class Employee
/// Department the employee works at
protected Employee(string name, Gender gender, string department)
{
- Name = string.Empty;
- Gender = Gender.Divers;
- Department = string.Empty;
- // TODO
+ Name = name;
+ Gender = gender;
+ Department = department;
}
///
@@ -29,7 +28,14 @@ public abstract class Employee
get => _name;
private init
{
- // TODO
+ if(value.Length < 2 || !char.IsUpper(value[0]) || char.IsDigit(value[0]))
+ {
+ _name = "ERROR";
+ }
+ else
+ {
+ _name = value;
+ }
}
}
@@ -54,8 +60,14 @@ public abstract class Employee
/// String representation of the employee
public override string ToString()
{
- // TODO
- return string.Empty;
+ string result = $"My name is {Name}";
+ if (Gender != Gender.Divers)
+ {
+ string genderString = $"{Gender}";
+ result += $", I identify as {genderString.ToLower()}";
+ }
+ result += $" and I work at the department {Department}";
+ return result;
}
}
diff --git a/Employees/Manager.cs b/Employees/Manager.cs
index 3ea4925..53bda6f 100644
--- a/Employees/Manager.cs
+++ b/Employees/Manager.cs
@@ -19,7 +19,7 @@ public sealed class Manager : OfficeEmployee
///
/// Gets the actual salary for the manger, which is higher than the base salary
///
- public override decimal Salary => -1M; // TODO
+ public override decimal Salary => base.Salary * 1.2M;
- public override string ToString() => string.Empty; // TODO
+ public override string ToString() => $"My name is {Name} and I'm head of the {Department} department";
}
diff --git a/Employees/OfficeEmployee.cs b/Employees/OfficeEmployee.cs
index 89c06d5..c7b93d2 100644
--- a/Employees/OfficeEmployee.cs
+++ b/Employees/OfficeEmployee.cs
@@ -16,10 +16,10 @@ public class OfficeEmployee : Employee
public OfficeEmployee(string name, Gender gender, string department,
decimal monthlySalary) : base(name, gender, department)
{
- // TODO
+ Salary = Math.Max(0M, monthlySalary);
}
public override decimal Salary { get; }
- public override string ToString() => string.Empty; // TODO
+ public override string ToString() => $"{base.ToString()} as an employee";
}
diff --git a/Employees/Worker.cs b/Employees/Worker.cs
index c3fd07c..851d723 100644
--- a/Employees/Worker.cs
+++ b/Employees/Worker.cs
@@ -34,7 +34,8 @@ public sealed class Worker : Employee
public Worker(string name, Gender gender, string department, double hours, decimal hourlyWage)
: this(name, gender, department)
{
- // TODO
+ Hours = hours;
+ HourlyWage = hourlyWage;
}
///
@@ -44,7 +45,7 @@ public sealed class Worker : Employee
public double Hours
{
get => _hours;
- set => _hours = -1D; // TODO
+ set => _hours = Math.Clamp(value, 0, MaxMonthlyWorkHours);
}
///
@@ -54,10 +55,10 @@ public sealed class Worker : Employee
public decimal HourlyWage
{
get => _hourlyWage;
- set => _hourlyWage = -1M; // TODO
+ set => _hourlyWage = Math.Max(0, value);
}
- public override decimal Salary => -1M; // TODO
+ public override decimal Salary => (decimal)Hours * HourlyWage;
- public override string ToString() => string.Empty; // TODO
+ public override string ToString() => $"{base.ToString()} as a worker";
}