import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Town a = new Town("A");
Town b = new Town("B");
Person layton = new Person();
layton.setName("Layton");
Person luke = new Person();
luke.setName("Luke");
Person badUncle = new Person();
badUncle.setName("Bad");
a.addPerson(layton);
a.addPerson(luke);
a.addPerson(badUncle);
while(b.getPeopleIndex() < 3){
if(layton.getPosition() != luke.getPosition() &&
luke.getPosition() == badUncle.getPosition()){
System.out.println("Luke가 강에 빠졌습니다ㅠㅠ");
System.exit(1);
}
a.showPeople();
b.showPeople();
System.out.print("강 건널 사람 몇 명(0~2)? ");
int num = input.nextInt();
int [] name = new int[num];
Person ship = new Person();
for(int i=0; i<num; i++){
System.out.print("건널 사람 이름?(Layton: 1, Luke: 2, Bad: 3)->");
name[i] = input.nextInt();
}
if(mustCheck(num,name)){
for(int i=0; i<num; i++){
switch(name[i]){
case 1:
ship = layton;
break;
case 2:
ship = luke;
break;
case 3:
ship = badUncle;
break;
}
if(a.getTownName().equals(ship.getPosition().getTownName())){
a.crossRiver(b, ship);
}else{
b.crossRiver(a, ship);
}
}
}
}
a.showPeople();
b.showPeople();
}
public static boolean mustCheck(int num, int [] name){
if(num > 2){
System.out.println("[Error] 배는 2인승이야!");
return false;
}
if(num == 1 && name[0]==2){//Luke 혼자 가면
System.out.println("[Error] Luke 혼자 못탐ㅋ");
return false;
}
return true;
}
}