-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompany.cs
41 lines (37 loc) · 962 Bytes
/
Company.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
using System;
using System.Collections.Generic;
namespace oop
{
class Company
{
private string _name;
public string Name
{
get => _name;
set => _name = value;
}
public Company(string name)
{
if (name.Length < 2) throw new Exception("Company name is too short");
this.Name = name;
}
public List<Department> departments = new List<Department>();
public void addDepartment(Department department)
{
this.departments.Add(department);
}
public void showCompany()
{
Console.WriteLine("\n----------------------\n");
Console.WriteLine($"Welcome to {this.Name} company");
showDepartments();
Console.WriteLine("\n----------------------\n");
}
public void showDepartments()
{
Console.WriteLine($"{this.Name} departments:");
foreach (Department department in this.departments)
Console.WriteLine($"{department.Name}");
}
}
}