Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Exam_Preparation_2_Fitness
- {
- public class Coach
- {
- //име, опит, списък от клиенти, пари
- private string name;
- private int experience;
- private List<Athlete> clients;
- private double money;
- public Coach(string name, int experience)
- {
- Name = name;
- Experience = experience;
- Money = 0;
- Clients = new List<Athlete>();
- }
- public Coach(string name, int experience, double money)
- {
- Name = name;
- Experience = experience;
- Money = money;
- Clients = new List<Athlete>();
- }
- public string Name
- {
- get
- {
- return name;
- }
- set
- {
- if (value.Length <= 2)
- {
- throw new ArgumentException("Invalid coach name!");
- }
- name = value;
- }
- }
- public int Experience
- {
- get
- {
- return experience;
- }
- set
- {
- experience = value;
- }
- }
- public List<Athlete> Clients
- {
- get
- {
- return clients;
- }
- set
- {
- clients = value;
- }
- }
- public double Money
- {
- get
- {
- return money;
- }
- set
- {
- money = value;
- }
- }
- public override string ToString()
- {
- //Coach: <име> has experience <опит> and his current money balace is: <пари>
- return $"Coach: {name} has experience {experience} and his current money balace is: {money:F2}";
- }
- public void AddNewClient(Athlete a)
- {
- clients.Add(a);
- }
- public bool LooseClient(string name)
- {
- foreach (Athlete client in clients)
- {
- if (client.Name == name)
- {
- return clients.Remove(client);
- }
- }
- return false;
- }
- public int GetClientsCount()
- {
- return clients.Count;
- }
- public List<Athlete> GetAllClientsTougherThan(double strength)
- {
- //ВСИЧКИ КЛИЕНТИ СЪС СИЛА > ОТ strength
- List<Athlete> stronger = new List<Athlete>();
- foreach (Athlete client in clients)
- {
- if (client.Strenght > strength)
- {
- stronger.Add(client);
- }
- }
- return stronger;
- }
- public void SpendMoneyOnSupplements(double amount)
- {
- if (amount > money)
- {
- throw new ArgumentException("Insufficient balance");
- }
- money -= amount;
- }
- public void TrainHard()
- {
- experience += 5;
- }
- public void TrainClient(Athlete athlete)
- {
- athlete.Strenght += 5;
- experience += 1;
- money += athlete.Strenght * 0.75;
- }
- public int RemoveAllClientsLeakerThan(int strength)
- {
- return clients.RemoveAll(a => a.Strenght < strength);
- }
- public Athlete GetToughestClient()
- {
- return clients.OrderByDescending(client => client.Strenght).First();
- }
- }
- }
Add Comment
Please, Sign In to add comment