Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BMI {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- String userName1;
- String userName2;
- int pile1 = 3;
- int pile2 = 4;
- int pile3 = 5;
- String kupka = "";
- int ile;
- int usrSwitch = 2;
- System.out.println("Podaj nazwe użytkownika nr 1: ");
- userName1 = input.nextLine();
- System.out.println("Podaj nazwe użytkownika nr 2: ");
- userName2 = input.nextLine();
- int counter = 1;
- while (counter != 0) {
- System.out.println("A: " + pile1 + " B: " + pile2 + " C: " + pile3);
- if (usrSwitch % 2 == 0) {
- System.out.println(userName1 + ", twoja kolej. Która kupka?");
- } else {
- System.out.println(userName2 + ", twoja kolej. Która kupka?");
- }
- kupka = input.next();
- while (pile1 == 0 && kupka.equalsIgnoreCase("A")) {
- System.out.println("Ta kupka jest pusta. Wybierz jeszcze raz: ");
- kupka = input.next();
- }
- while (pile2 == 0 && kupka.equalsIgnoreCase("B")) {
- System.out.println("Ta kupka jest pusta. Wybierz jeszcze raz: ");
- kupka = input.next();
- }
- while (pile3 == 0 && kupka.equalsIgnoreCase("C")) {
- System.out.println("Ta kupka jest pusta. Wybierz jeszcze raz: ");
- kupka = input.next();
- }
- if (kupka.equalsIgnoreCase("A")) {
- System.out.println("Ile chcesz zabrać?");
- ile = input.nextInt();
- while (ile > pile1 || ile < 0) {
- System.out.println("Nie wolno oszukiwać! Spróbuj jeszcze raz!");
- ile = input.nextInt();
- }
- pile1 = pile1 - ile;
- }
- if (kupka.equalsIgnoreCase("B")) {
- System.out.println("Ile chcesz zabrać?");
- ile = input.nextInt();
- while (ile > pile2 || ile < 0) {
- System.out.println("Nie wolno oszukiwać! Spróbuj jeszcze raz!");
- ile = input.nextInt();
- }
- pile2 = pile2 - ile;
- }
- if (kupka.equalsIgnoreCase("C")) {
- System.out.println("Ile chcesz zabrać?");
- ile = input.nextInt();
- while (ile > pile3 || ile < 0) {
- System.out.println("Nie wolno oszukiwać! Spróbuj jeszcze raz!");
- ile = input.nextInt();
- }
- pile3 = pile3 - ile;
- }
- if (pile3 == 0 && pile1 == 0 && pile2 == 0) {
- counter = 0;
- }
- usrSwitch += 1;
- }
- if (usrSwitch % 2 == 0) {
- System.out.println("Gra zakonczona, przegrał " + userName2);
- } else {
- System.out.println("Gra zakonczona, przegrał " + userName1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement