Skip to content

Commit

Permalink
Lab6
Browse files Browse the repository at this point in the history
  • Loading branch information
Gungniir committed Oct 15, 2021
1 parent d0126cc commit e557120
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lab6/Cashier.cs
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 "Пополняю транспортные карты";
}
}
}
25 changes: 25 additions & 0 deletions lab6/Employee.cs
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 "Работаю";
}
}
}
17 changes: 17 additions & 0 deletions lab6/Operator.cs
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 "Ищу посылку";
}
}
}
48 changes: 48 additions & 0 deletions lab6/PostOffice.cs
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) + " |");
}
}
}
17 changes: 17 additions & 0 deletions lab6/Postman.cs
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 "Разношу почту, не мешайте";
}
}
}
41 changes: 41 additions & 0 deletions lab6/Program.cs
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();
}
}
}
8 changes: 8 additions & 0 deletions lab6/lab6.csproj
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>
18 changes: 18 additions & 0 deletions university.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lab5", "lab5", "{BB7A5829-A
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab5", "lab5\lab5.csproj", "{20BCE9AC-870E-448B-B56D-30A896680157}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lab6", "lab6", "{948DD9AF-1189-4F68-ADA9-268091F1D3A4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab6", "lab6\lab6.csproj", "{132B17F7-D8FF-490A-A228-CAD1EC1F67A4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lab7", "lab7", "{B42884FB-677F-461A-8F5C-24C9B804A7B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab7", "lab7\lab7.csproj", "{DCAF9638-4D03-4FF0-ADEA-198A05CB3454}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -50,6 +58,8 @@ Global
{84469DF2-D887-4C0C-BD15-E89C6B6DCF35} = {8D5EC179-48B3-4433-B9B3-702DB8E41C5D}
{EC116774-757C-4F19-96FF-C33FA6E083DB} = {849CD516-AC6A-487A-AC26-10315BBBCA14}
{20BCE9AC-870E-448B-B56D-30A896680157} = {BB7A5829-AB7C-4A1F-889A-0A7E28F7B648}
{132B17F7-D8FF-490A-A228-CAD1EC1F67A4} = {948DD9AF-1189-4F68-ADA9-268091F1D3A4}
{DCAF9638-4D03-4FF0-ADEA-198A05CB3454} = {B42884FB-677F-461A-8F5C-24C9B804A7B9}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E95BBBCC-BDF7-4D5C-8603-55E407B4318E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -100,5 +110,13 @@ Global
{20BCE9AC-870E-448B-B56D-30A896680157}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20BCE9AC-870E-448B-B56D-30A896680157}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20BCE9AC-870E-448B-B56D-30A896680157}.Release|Any CPU.Build.0 = Release|Any CPU
{132B17F7-D8FF-490A-A228-CAD1EC1F67A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{132B17F7-D8FF-490A-A228-CAD1EC1F67A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{132B17F7-D8FF-490A-A228-CAD1EC1F67A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{132B17F7-D8FF-490A-A228-CAD1EC1F67A4}.Release|Any CPU.Build.0 = Release|Any CPU
{DCAF9638-4D03-4FF0-ADEA-198A05CB3454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCAF9638-4D03-4FF0-ADEA-198A05CB3454}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCAF9638-4D03-4FF0-ADEA-198A05CB3454}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCAF9638-4D03-4FF0-ADEA-198A05CB3454}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit e557120

Please sign in to comment.