-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAthlete.cs
More file actions
21 lines (19 loc) · 888 Bytes
/
Athlete.cs
File metadata and controls
21 lines (19 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
namespace Health;
// Classe derivada para atletas, ajustando o cálculo do IMC
public class Athlete(IHealthRules rules, double weight, double height) : Person(rules, weight, height)
{
// Sobrescreve o IMC para aplicar um ajuste específico para atletas
public override double IMC
{
get
{
double baseIMC = base.IMC; // Chama o IMC da classe base (Person)
return baseIMC * 0.9; // Reduz 10% para refletir massa muscular
}
}
// Comentário: Athlete herda de Person e ajusta o IMC, usando a mesma dependência
// IHealthRules injetada pelo contêiner.
// SOLID - S (Single Responsibility): Responsável apenas por ajustar o IMC para atletas.
// SOLID - O (Open/Closed): Extende Person sem modificar seu código.
// SOLID - L (Liskov Substitution): Pode substituir Person, mantendo um IMC válido.
}