-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
57 lines (46 loc) · 2.23 KB
/
Program.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
using Exercise_01_WorkerContracts.Entities;
using Exercise_01_WorkerContracts.Entities.Enums;
using System;
using System.Globalization;
namespace Exercise_01_WorkerContracts
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter department's name: ");
string deptName = Console.ReadLine();
Console.WriteLine("Enter worker data: ");
Console.Write("Name: ");
string name = Console.ReadLine();
Console.Write("Level (Junior/MidLevel/Senior): ");
WorkerLevel level = Enum.Parse<WorkerLevel>(Console.ReadLine());
Console.Write("Base salary: ");
double baseSalary = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
Department dept = new Department(deptName);
Worker worker = new Worker(name, level, baseSalary, dept);
Console.Write("How many contracts to this employ? ");
int n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
Console.WriteLine($"Enter #{i} contract data: ");
Console.Write("Date (DD/MM/YYYY): ");
DateTime date = DateTime.Parse(Console.ReadLine());
Console.Write("Value per hour: ");
double valuePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
Console.Write("Duration (hours): ");
int hours = int.Parse(Console.ReadLine());
HourContract contract = new HourContract(date, valuePerHour, hours);
worker.AddContract(contract);
}
Console.WriteLine();
Console.Write("Enter month and year to calculate income (MM/YYYY): ");
string monthAndYear = Console.ReadLine();
int month = int.Parse(monthAndYear.Substring(0,2));
int year = int.Parse(monthAndYear.Substring(3));
Console.WriteLine("Name: " + worker.Name);
Console.WriteLine("Departament: " + worker.Departament.Name);
Console.WriteLine("Income for " + monthAndYear + ": " + worker.Income(year, month).ToString("F2",CultureInfo.InvariantCulture));
}
}
}