Skip to content

Commit

Permalink
Lab 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Gungniir committed Oct 15, 2021
1 parent e557120 commit 3b7f08b
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 3 deletions.
12 changes: 12 additions & 0 deletions lab7/Cashier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace lab7
{
public class Cashier : Employee
{
public string Qualification { get; set; }

public override string GetFullName()
{
return base.GetFullName() + " | " + Qualification;
}
}
}
73 changes: 73 additions & 0 deletions lab7/Commander.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualBasic;

namespace lab7
{
public class Commander
{
public Commander()
{
Employees = new List<Employee>();
TomorrowEmployees = new List<Employee>();
}

public List<Employee> Employees { get; set; }
public List<Employee> TomorrowEmployees { get; set; }

public void PrintTeam()
{
_printHr();
_printMiddle("Завтрашняя смена");
_printHr();
foreach (Employee employee in TomorrowEmployees)
{
_print(employee.GetFullName());
}
_printHr();
}

public static void PrintBage(Cashier cashier)
{
_printHr();
_printMiddle("Кассир Командора");
_printHr();
_print(cashier.GetFullName());
_printHr();
}

public void PrintBageForAllCashiers()
{
foreach (Employee employee in Employees)
{
if (employee is not Cashier)
{
continue;
}

_printHr();
_printMiddle("Кассир Командора");
_printHr();
_print(employee.GetFullName());
_printHr();

Console.WriteLine();
}
}

private static void _printHr()
{
Console.WriteLine("+" + new string('-', 50) + "+");
}

private static void _print(string text)
{
Console.WriteLine("| " + text + new string(' ', 50-2-text.Length) + " |");
}

private static void _printMiddle(string text)
{
Console.WriteLine("| " + new string(' ', (50-2-text.Length)/2) + text + new string(' ', (50-2-text.Length)/2 + (50-2-text.Length)%2) + " |");
}
}
}
15 changes: 15 additions & 0 deletions lab7/Employee.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace lab7
{
public class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }

public virtual string GetFullName()
{
return $"{FirstName} {LastName}";
}
}
}
7 changes: 7 additions & 0 deletions lab7/Loader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace lab7
{
public class Loader : Employee
{

}
}
29 changes: 29 additions & 0 deletions lab7/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;

namespace lab7
{
class Program
{
static void Main(string[] args)
{
string[] names = {"Иван", "Владимир", "Михаил", "Алексей", "Кирилл", "Матвей", "Костя", "Виктор", "Денис", "Николай", "Александр"};
string[] surnames = {"Ванюшкин", "Курусь", "Кибалин", "Викторов", "Нагель", "Казимирский", "Поздняков", "Пенский", "Калинин", "Ткачев", "Скурихин"};
string[] qualifications = {"стажер", "кассир", "старший кассир"};

Commander commander = new Commander();

Random random = new Random();
for (int i = 0; i < 8; i++)
{
Cashier cashier = new Cashier();
cashier.Qualification = qualifications[random.Next(qualifications.Length)];

cashier.FirstName = names[random.Next(names.Length)];
cashier.LastName = surnames[random.Next(surnames.Length)];
commander.Employees.Add(cashier);
}

commander.PrintBageForAllCashiers();
}
}
}
8 changes: 8 additions & 0 deletions lab7/lab7.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>
3 changes: 0 additions & 3 deletions university.sln.DotSettings.user

This file was deleted.

0 comments on commit 3b7f08b

Please sign in to comment.