This is actually one of the questions that I took from IB tech interview. It was a pair programming interview that writing a simple cashier program. I had no problem playing with OOP, but the I couldn't answer/write one of the requirement that interviewer asked.
Is it possible to write a buy two one free OOP program that does not use the attribute of the class? The number of buying/free items doesn't matter. I tried to implement this by giving attribute to the item to check whether this is on the event sale or not. It turns out there must be a better, elegant way to do this. I cannot think out of the way how to do this without attribute. I think this is related to design pattern problem, but I can't come up with out solution to this. Anybody has any idea about this? This is, by the way, language-agnostic question as I know.
Aucun commentaire:
Enregistrer un commentaire