A goalkeeper is a Player with specialized turn behavior. The class diagram must preserve inheritance and the operation that is overridden.
These complete class definitions increment a normal turn count and, for a Goalkeeper, also a save-practice count.
public class Player
{
public int NumberOfTurns;
public virtual void RecordTurn()
{
NumberOfTurns = NumberOfTurns + 1;
}
}
public class Goalkeeper : Player
{
public int SavesPracticed;
public override void RecordTurn()
{
base.RecordTurn();
SavesPracticed = SavesPracticed + 1;
}
}Define Player with a stored turn count and a virtual RecordTurn operation
Define Goalkeeper as a derived Player
Add its SavesPracticed field
Override the inherited RecordTurn contract
The override calls the base body before its own updateThese words describe the class contract, not a sequence of runtime actions. Identify the types, stored members, operation inputs and results, and relationships before choosing compartments and connectors.
Player above Goalkeeper.+NumberOfTurns : int and +RecordTurn() : void in Player's attributes and operations. Put +SavesPracticed : int and +RecordTurn() : void in Goalkeeper's corresponding compartments.RecordTurn is virtual in C# for Player and RecordTurn overrides Player.RecordTurn and calls the base body first for Goalkeeper.Compare this reference with the diagram you built in Violet. Layout may differ; the source meaning, labels, and relevant connections should agree.
Goalkeeper inherits NumberOfTurns; the class diagram does not need to redeclare that field in the derived compartment. The operation entry in Goalkeeper represents overriding, not another object.