SHOW:
|
|
- or go back to the newest paste.
| 1 | using System; | |
| 2 | using System.Collections.Generic; | |
| 3 | using System.Collections.Specialized; | |
| 4 | using System.Text; | |
| 5 | using System.Threading.Tasks; | |
| 6 | using System.Net; | |
| 7 | using System.Threading; | |
| 8 | ||
| 9 | namespace IMJunior | |
| 10 | {
| |
| 11 | class Program | |
| 12 | {
| |
| 13 | static void Main() | |
| 14 | {
| |
| 15 | while (true) | |
| 16 | {
| |
| 17 | string command = Console.ReadLine(); | |
| 18 | Departament[] deppartaments = new Departament[10]; | |
| 19 | ||
| 20 | UsersDatabase database = new UsersDatabase(); | |
| 21 | Formater formater = new Formater(15); | |
| 22 | UsersListDrawer drawer = new UsersListDrawer(database, formater); | |
| 23 | ||
| 24 | DepartamentDrawer departamentDrawer = new DepartamentDrawer(null, formater); | |
| 25 | ||
| 26 | if(command == "UserList") | |
| 27 | {
| |
| 28 | drawer.Draw(); | |
| 29 | } | |
| 30 | if(command == "DepartamentList") | |
| 31 | {
| |
| 32 | departamentDrawer.Draw(); | |
| 33 | } | |
| 34 | } | |
| 35 | } | |
| 36 | } | |
| 37 | ||
| 38 | class UsersDatabase | |
| 39 | {
| |
| 40 | private User[] users; | |
| 41 | ||
| 42 | public void Add(User user) | |
| 43 | {
| |
| 44 | ||
| 45 | } | |
| 46 | ||
| 47 | public void Remove(User user) | |
| 48 | {
| |
| 49 | ||
| 50 | } | |
| 51 | ||
| 52 | public User[] GetAll() | |
| 53 | {
| |
| 54 | throw new NotImplementedException(); | |
| 55 | } | |
| 56 | } | |
| 57 | ||
| 58 | class UsersListDrawer | |
| 59 | {
| |
| 60 | private readonly UsersDatabase _database; | |
| 61 | private readonly Template _template; | |
| 62 | ||
| 63 | public UsersListDrawer(UsersDatabase database, Formater formater) | |
| 64 | {
| |
| 65 | _database = database; | |
| 66 | _template = new Template(formater); | |
| 67 | } | |
| 68 | ||
| 69 | public void Draw() | |
| 70 | {
| |
| 71 | foreach (var item in _database.GetAll()) | |
| 72 | {
| |
| 73 | _template.Draw(item.Name, item.Salary); | |
| 74 | } | |
| 75 | } | |
| 76 | } | |
| 77 | ||
| 78 | class DepartamentDrawer | |
| 79 | {
| |
| 80 | ||
| 81 | private readonly Departament[] _database; | |
| 82 | private readonly Template _template; | |
| 83 | ||
| 84 | public DepartamentDrawer(Departament[] database, Formater formater) | |
| 85 | {
| |
| 86 | _database = database; | |
| 87 | _template = new Template(formater); | |
| 88 | } | |
| 89 | ||
| 90 | public void Draw() | |
| 91 | {
| |
| 92 | foreach (var item in _database) | |
| 93 | {
| |
| 94 | _template.Draw(item.Name, item.WorkerCount); | |
| 95 | } | |
| 96 | } | |
| 97 | } | |
| 98 | ||
| 99 | class Template | |
| 100 | {
| |
| 101 | private readonly Formater _formater; | |
| 102 | ||
| 103 | public Template(Formater formater) | |
| 104 | {
| |
| 105 | this._formater = formater; | |
| 106 | } | |
| 107 | ||
| 108 | public void Draw(string data, int numericData) | |
| 109 | {
| |
| 110 | Console.WriteLine($"{_formater.Format(data)} | {_formater.Format(numericData)}");
| |
| 111 | } | |
| 112 | } | |
| 113 | ||
| 114 | class User | |
| 115 | {
| |
| 116 | public string Name; | |
| 117 | public int Money; | |
| 118 | public int Salary; | |
| 119 | } | |
| 120 | ||
| 121 | class Departament | |
| 122 | {
| |
| 123 | public string Name; | |
| 124 | public int WorkerCount; | |
| 125 | public int AspirantCount; | |
| 126 | } | |
| 127 | } |