Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mathSkillTest;
- import java.util.Scanner;
- public class Main {
- public static void main(String args[]) {
- Number number = new Number();
- int a = number.getFirstNumber(), b = number.getSecondNumber(),
- result = number.getResult(), userResult = number.getUserResult(),
- attempt, shoot = number.getShoot();
- Scanner scan = new Scanner(System.in);
- System.out.println("How many attempts you need? ");
- attempt = scan.nextInt();
- number.setAttempts(attempt);
- String life = "<3";
- System.out.println(a + " + " + b + " = ");
- while(userResult != result && attempt != 0) {
- System.out.print("You have " + attempt + " lifes ");
- for(int i = 0; i < attempt; i++) {
- System.out.print(life + " ");
- }
- System.out.println();
- shoot++;
- userResult = scan.nextInt();
- if(userResult != result) {
- attempt--;
- System.out.println("Wrong, try again.");
- if(attempt == 0)
- System.out.println("you lost");
- }
- else {
- if(shoot == 1)
- System.out.println("Congrats. You did it in "+ shoot + " attempt.");
- else
- System.out.println("Congrats. You did it in "+ shoot + " attempts.");
- }
- }
- scan.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement