Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- string[] names = {
- "Joergen",
- "Watersheep",
- "Klaus",
- "Herbert",
- "Heinrich",
- "Günther"
- };
- People people = new People(names);
- people.PrintAllNames();
- Console.WriteLine();
- people.KillAllPeople();
- Console.ReadLine();
- }
- class Person
- {
- private string _Name { get; set; }
- public bool IsDead { get; set; }
- public Person(string name)
- {
- this._Name = name;
- this.IsDead = false;
- }
- public string GetName()
- {
- return this._Name;
- }
- public void Kill()
- {
- this.IsDead = true;
- Console.WriteLine($"{this._Name} was like a father to me...");
- }
- }
- class People
- {
- private List<Person> _People { get; set; }
- public People(string[] names)
- {
- this._People = new List<Person>();
- foreach (string name in names)
- {
- this._People.Add(new Person(name));
- }
- }
- public void PrintAllNames()
- {
- foreach (Person person in _People)
- {
- Console.WriteLine(person.GetName());
- }
- }
- public void KillAllPeople()
- {
- foreach (Person person in _People)
- {
- person.Kill();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement