mardi 16 février 2016

Design pattern - two different return types

My lecturer asked us to write some code in Python. The idea is - we provide number in text form to our class and it returns a number in integer or float type.

Examples:

Input: "two hundred and one"

Output: 201 (integer)

Input: "two point six"

Output: 2.6 (float)

He also asked us to use "suitable design pattern". I know how to write an algorithm, but i have no idea which design pattern i should use, so i can manage multiple return types. I might sound ignorant and my explanation is pretty vague, but you must know we didn't have any kind of introduction to this subject and we are pretty much on our own.

Aucun commentaire:

Enregistrer un commentaire