Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 알고리즘
- 코테
- 프로그래머스
- 문자열
- 코딩테스트
- 시뮬레이션
- SQL
- COS PRO
- SWEA
- greedy
- oracle
- 백준
- 건강
- 투포인터
- binary search
- priorityqueue
- 자바
- dfs
- 문제해결
- 러닝일지
- BFS
- db
- Java
- math
- 문제풀이
- BOJ
- 운동기록
- DP
- MySQL
- 이분탐색
Archives
- Today
- Total
슈콩
COS PRO 1급 JAVA PRG스토리 본문





[소스 코드]
import java.util.Arrays;
class Main {
class Unit {
public int HP;
public Unit() {
this.HP = 1000;
}
public void underAttack(int damage) { }
}
class Monster extends Unit {
public int attackPoint;
public Monster(int attackPoint) {
this.attackPoint = attackPoint;
}
public void underAttack(int damage) {
this.HP -= damage;
}
public int attack() {
return attackPoint;
}
}
class Warrior extends Unit {
public int attackPoint;
public Warrior(int attackPoint) {
this.attackPoint = attackPoint;
}
public void attack(int damage) {
this.HP -= damage;
}
public int attack() {
return attackPoint;
}
}
class Healer extends Unit {
public int healingPoint;
public Healer(int healingPoint) {
this.healingPoint = healingPoint;
}
public void underAttack(int damage) {
this.HP -= damage;
}
public void healing(Unit unit) {
unit.HP += healingPoint;
}
}
public int[] solution(int monsterAttackPoint, int warriorAttackPoint, int healingPoint) {
Monster monster = new Monster(monsterAttackPoint);
Warrior warrior = new Warrior(warriorAttackPoint);
Healer healer = new Healer(healingPoint);
//전사가 몬스터를 한 번 공격
monster.underAttack(warrior.attack());
//몬스터가 전사를 한 번 공격
warrior.underAttack(monster.attack());
//몬스터가 힐러를 한 번 공격
healer.underAttack(monster.attack());
//힐러가 전사의 체력을 한 번 회복
healer.healing(warrior);
//힐러가 몬스터의 체력을 한 번 회복
healer.healing(monster);
int[] answer = {monster.HP, warrior.HP, healer.HP};
return answer;
}
}