This will mostly get duplicated but I sincerely don\'t know how to search this question since it is too long and complicated. Sorry in advance!
Back to the problem,
So if you enter defend or attack, it will not ask again, otherwise repeat the process. Try this:
do{
String input = scan.nextLine();
switch( input) {
case "attack":
System.out.println( "You attacked the enemy!");
break;
case "defend":
System.out.println( "You blocked the enemy!");
break;
default:
System.out.println( "This is not an option!");
// somehow repeat the process until one of the case options are
// entered.
}
}while(!"attack".equalsIgnoreCase(input) || !"defend".equalsIgnoreCase(input))