-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace lab6 | ||
{ | ||
public class Cashier : Employee | ||
{ | ||
public override int WorkTime() | ||
{ | ||
return DateTime.Now.Subtract(DateOfEmployment).Days; | ||
} | ||
|
||
public override string WhatYouDo() | ||
{ | ||
return "Пополняю транспортные карты"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
|
||
namespace lab6 | ||
{ | ||
public class Employee | ||
{ | ||
public string Name { get; set; } | ||
public DateTime DateOfEmployment { get; set; } | ||
|
||
public string Say() | ||
{ | ||
return Name; | ||
} | ||
|
||
public virtual int WorkTime() | ||
{ | ||
return 0; | ||
} | ||
|
||
public virtual string WhatYouDo() | ||
{ | ||
return "Работаю"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace lab6 | ||
{ | ||
public class Operator : Employee | ||
{ | ||
public override int WorkTime() | ||
{ | ||
return DateTime.Now.Subtract(DateOfEmployment).Days / 30; | ||
} | ||
|
||
public override string WhatYouDo() | ||
{ | ||
return "Ищу посылку"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.VisualBasic; | ||
|
||
namespace lab6 | ||
{ | ||
public class PostOffice | ||
{ | ||
public List<Employee> Employees { get; set; } | ||
|
||
public void Poll() | ||
{ | ||
foreach (Employee employee in Employees) | ||
{ | ||
_printHr(); | ||
_print($"Работник: {employee.Name}"); | ||
_printHr(); | ||
_print("Как вас зовут?"); | ||
_print(employee.Say()); | ||
_printHr(); | ||
_print("Что вы делаете?"); | ||
_print(employee.WhatYouDo()); | ||
_printHr(); | ||
_print("И давно вы тут работаете?"); | ||
string n = employee switch | ||
{ | ||
Cashier => "д.", | ||
Operator => "м.", | ||
_ => "г." | ||
}; | ||
_print($"{employee.WorkTime()} {n}"); | ||
_printHr(); | ||
|
||
Console.WriteLine(); | ||
} | ||
} | ||
|
||
private void _printHr() | ||
{ | ||
Console.WriteLine("+" + new string('-', 50) + "+"); | ||
} | ||
|
||
private void _print(string text) | ||
{ | ||
Console.WriteLine("| " + text + new string(' ', 50-2-text.Length) + " |"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace lab6 | ||
{ | ||
public class Postman : Employee | ||
{ | ||
public override int WorkTime() | ||
{ | ||
return DateTime.Now.Subtract(DateOfEmployment).Days / 365; | ||
} | ||
|
||
public override string WhatYouDo() | ||
{ | ||
return "Разношу почту, не мешайте"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace lab6 | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
string[] names = {"Иван", "Владимир", "Михаил", "Алексей", "Кирилл", "Матвей", "Костя", "Виктор", "Денис", "Николай", "Александр"}; | ||
string[] surnames = {"Ванюшкин", "Курусь", "Кибалин", "Викторов", "Нагель", "Казимирский", "Поздняков", "Пенский", "Калинин", "Ткачев", "Скурихин"}; | ||
|
||
PostOffice postOffice = new PostOffice(); | ||
postOffice.Employees = new List<Employee>(); | ||
|
||
Random random = new Random(); | ||
for (int i = 0; i < 8; i++) | ||
{ | ||
Employee employee; | ||
switch (random.Next(0,2)) | ||
{ | ||
case 0: | ||
employee = new Postman(); | ||
break; | ||
case 1: | ||
employee = new Cashier(); | ||
break; | ||
default: | ||
employee = new Operator(); | ||
break; | ||
} | ||
employee.Name = names[random.Next(names.Length - 1)] + " " + | ||
surnames[random.Next(surnames.Length - 1)]; | ||
employee.DateOfEmployment = new DateTime(random.Next(2000, 2020), random.Next(1,12), random.Next(1,28)); | ||
postOffice.Employees.Add(employee); | ||
} | ||
|
||
postOffice.Poll(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters