refactors triangle and area functions to be more object-oriented