Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace SpaceStationRecruitment
- {
- class SpaceStation
- {
- public string Name { get; set; }
- public int Capacity { get; set; }
- private List<Astronaut> data;
- public SpaceStation(string Name, int Capacity)
- {
- this.Name = Name;
- this.Capacity = Capacity;
- data = new List<Astronaut>();
- }
- public void Add(Astronaut astronaut)
- {
- if (Capacity > 0)
- {
- data.Add(astronaut);
- Capacity--;
- }
- }
- public bool Remove(string name)
- {
- bool result = false;
- foreach (var item in data)
- {
- if (item.Name == name)
- {
- data.Remove(item);
- result = true;
- }
- }
- return result;
- }
- public Astronaut GetOldestAstronaut()
- {
- int age = int.MinValue;
- foreach (var item in data)
- {
- if (item.Age >= age)
- {
- age = item.Age;
- }
- }
- var newAstronaut = new Astronaut("asaa", 1, "asasa");
- foreach (var item in data)
- {
- if (item.Age == age)
- {
- newAstronaut = item;
- }
- }
- return newAstronaut;
- }
- public Astronaut GetAstronaut(string name)
- {
- var NewAstronaut = new Astronaut("Ivan", 0, "Plovdiv");
- foreach (var item in data)
- {
- if (item.Name == name)
- {
- NewAstronaut = item;
- }
- }
- return NewAstronaut;
- }
- public int Count()
- {
- return data.Count;
- }
- public string Report()
- {
- string result = $"Astronauts working at Space Station {Name}:\n";
- foreach (var item in data)
- {
- result += $"Astronaut: {item.Name}, {item.Age} ({item.Country})\n";
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement