Course Object Oriented Programming
Coding an Example
Let's now code an example.
Example
Let's use the example given in the previous class, about the "Pillar 1: Abstraction".
Imagine that we want to make a programme that receives data from three people and prints the oldest person's name and, in case of a tie, the names of all the oldest people.
Abstraction of the example
As we have seen before, we can abstract the problem in the following way:
- Create a class person;
- Create three objects from the person class;
- Execute the reading of the objects' data;
- Determine the age of the oldest;
- Present the names of the oldest people.