What is a better way to write the code,
public void showFeelings(int howManyGoals)
{
switch (howManyGoals)
{
case 0: System.out.println("Oh dear, not very good"); break;
case 1: System.out.println("Oh dear, not very good"); break;
case 2: System.out.println("Oh dear, not very good"); break;
case 3: System.out.println("Ive seen donkeys shoot better"); break;
case 4: System.out.println("Ive seen donkeys shoot better"); break;
case 5: System.out.println("Ive seen donkeys shoot better"); break;
//and so on
}
}
Is there a possible way of writing cases 0-2 as one case or am i better writing it as follows
public void showFeelings(int howManyGoals)
{
if(howManyGoals >= 0 && howManyGoals <= 2)
{
System.out.println("Oh dear, not very good");
}
else if(howManyGoals >= 0 && howManyGoals <= 2)
{
System.out.println("Ive seen donkeys shoot better");
}
// and so on
}
I think i've answered my own question as ive thought that at some stage i will need to end it so i will need something like howManyGoals being more than says your an "international hero" but i dont think i am able to do this with switch statements?
Thanks