if
, switch
are few of those control statements which help us to do the conditional operation. If we think about a situation, in where we need to do multiple tasks for each of the condition for example, if user select display Computer details then we need to write few statements to display Computer information or if they select to display Processor information also require to write few statements. To make code elegant we will probably move all those statements on its own method
block and run those methods
based on the condition.To describe the situation I created an
enum
which defines our conditions,
No comments:
Post a Comment