import java.util.
Scanner;
public class Play {
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean finish = false;
int life,assault,block,blocks,damage,height;
assault = 1;
life = 100;
blocks = 1;
damage = 1;
Scanner entry = new Scanner(System.in);
System.out.println("Welcome to the game\r\n"+"\r\n");
while (finish == false) {
height = (int) (Math.random() * 2);
System.out.println("Assault #"+ assault +"\r\n");
System.out.println("The monster is attacking. PROTEGATE!");
System.out.println("Choose your block (0 for bottom, 1 for
middle, 2 for top): ");
block = entry.nextInt();
if (block != height) {
damage = (int) (Math.random() * 30);
System.out.println("\r\n" + "You didn't block the blow");
System.out.println("- Damage received: " + damage);
life = life - damage;
System.out.println("- Remaining life: " + life + "\r\n" +
"--------------\r\n" + "\r\n");
blocks = 1;
}
else if (block == height) {
System.out.println("\r\n" + "You blocked the blow!");
System.out.println("- Remaining life: " + life + "\r\
n"+"--------------\r\n" + "\r\n");
blocks++;
if (blocks == 3) {
life = life + 5;
blocks = 1;
}
}
if (life <= 0 || assault >= 15) {
finish = true;
}
else {
assault++;
}
}
System.out.println("End of game.");
System.out.println("Remaining life: " + life);
System.out.println("Remaining rounds: " + assault);
}
}