import java.util.Scanner;

class Game {
Scanner sc = new Scanner(System.in);
String name;
static int resourse = 100; // 공유자원
boolean play() {
    System.out.println(this.name + "님 얼마나 깍을지 입력하세요.");
    resourse -= sc.nextInt();
    if (resourse < 0) {
        System.out.println(this.name + "님이 패배하셧습니다.");
        return true;
    }
    return false;
}

Game(String name) {
    this.name = name;
}
}

public class Sandcatle {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("플레이어 수 입력 : ");
int num = sc.nextInt();
int[] player = new int[num];
Game[] g = new Game[player.length];
for (int i = 0; i < player.length; i++) {
System.out.print((i + 1) + "번째 플레이어 이름 입력 : ");
g[i] = new Game(sc.next());
}
int index = 0;
while (true) {
        if (g[index].play()) {
            System.out.println("Game Over");
            break;
        }

        index++;
        if (g.length == index) {
            index = 0;
        }

    }

}
}

 

+ Recent posts