Mercado Livre interview question

Basic OOP questions, a live algorithm