Course Object Oriented Programming

Coding an Example

Course's Page 13 min Text by
User Image
Allan Garcia

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:

  1. Create a class person;
  2. Create three objects from the person class;
  3. Execute the reading of the objects' data;
  4. Determine the age of the oldest;
  5. Present the names of the oldest people.

Abstraction of Struct