public class Pokemon {
private String name;
private String type;
private String skill;
private int hp;
private int atk;
public Pokemon(String name, String type, String skill, int hp, int atk) {
this.name = name;
this.type = type;
this.skill = skill;
this.hp = hp;
this.atk = atk;
}
public Pokemon() {
}
public void setHp(int hp) {
this.hp = hp;
}
public void setAtk(int atk) {
this.atk = atk;
}
public String getName() {
return name;
}
public String getType() {
return type;
}
public String getSkill() {
return skill;
}
public int getHp() {
return hp;
}
public int getAtk() {
return atk;
}
}
mport java.util.Scanner;
public class PokemonMain {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Pokemon kkobuk = new Pokemon("꼬부기", "물", "물대포", 100, 10);
Pokemon pika = new Pokemon("피카츄", "전기", "백만볼트", 110, 15);
while (true) {
boolean myTun = false;
System.out.println("==== 포켓몬을 선택하세요 ====");
System.out.print("[1]꼬부기 [2]피카츄 >> ");
int choice = sc.nextInt();
if (choice == 1) {
System.out.println("==== 공격을 선책하세요 ====");
System.out.print("[1]일반공격 [2]스킬공격 >> ");
int atteck = sc.nextInt();
if (atteck == 1) {
System.out.println(kkobuk.getName() + "가 일반공격을 했다 ! ");
System.err.println(pika.getName() + "가 " + kkobuk.getAtk() + " 만큼 타격을 받았다..! ");
pika.setHp(pika.getHp() - kkobuk.getAtk());
} else if(atteck == 2) {
System.out.println(kkobuk.getName() + "가 "+kkobuk.getSkill()+" 스킬을 사용했다 ! ");
System.err.println(pika.getName() + "는 " + (int)(kkobuk.getAtk()*1.5) + " 만큼 타격을 받았다..! ");
pika.setHp(pika.getHp() - (int)(kkobuk.getAtk()*1.5));
} else {
System.out.println(kkobuk.getName() + "가 공격이 미끄러졌다... ");
}
System.out.println(pika.getName() + " hp : " + pika.getHp());
System.out.println(kkobuk.getName() + " hp : " + kkobuk.getHp());
} else if (choice == 2) {
System.out.println("==== 공격을 선책하세요 ====");
System.out.println("[1]일반공격 [2]스킬공격 >> ");
int atteck = sc.nextInt();
if (atteck == 1) {
System.out.println(kkobuk.getName() + "가 일반공격을 했다 ! ");
System.err.println(pika.getName() + "가 " + kkobuk.getAtk() + " 만큼 타격을 받았다..! ");
pika.setHp(pika.getHp() - kkobuk.getAtk());
} else if(atteck == 2) {
System.out.println(kkobuk.getName() + "가 "+kkobuk.getSkill()+" 스킬을 사용했다 ! ");
System.err.println(pika.getName() + "는 " + (int)(kkobuk.getAtk()*1.5) + " 만큼 타격을 받았다..! ");
pika.setHp(pika.getHp() - (int)(kkobuk.getAtk()*1.5));
} else {
System.out.println(kkobuk.getName() + "가 공격이 미끄러졌다... ");
}
System.out.println(pika.getName() + " hp : " + pika.getHp());
System.out.println(kkobuk.getName() + " hp : " + kkobuk.getHp());
} else {
System.out.println("다시 포켓몬을 선택해주세요.");
}
if (kkobuk.getHp() <= 0) {
System.out.println("===============");
System.out.println("꼬부기가 쓰러졌다...");
System.out.println("피카츄 승리 ! ");
System.out.println("===============");
break;
} else if (pika.getHp() <= 0) {
System.out.println("===============");
System.out.println("피카츄가 쓰러졌다...");
System.err.println("꼬부기 승리 ! ");
System.out.println("===============");
break;
}
}
}
}