ìˆ™ì œ ¶
ë‘�번째ë‚
Unit ¶
~cpp
public class Unit {
protected int unitHp;
protected int unitShield;
protected int attackPoint;
private boolean airAttack;
protected String nowState;
public String name;
public Unit() {
}
public Unit(int hp, int shield, int attack, String state, boolean air) {
this.unitHp = hp;
this.unitShield = shield;
this.attackPoint = attack;
this.nowState = state;
this.airAttack = air;
}
//사용� 안�었네요.
/*
* public String changeState(String aState) { this.nowState = aState; return
* nowState; }
*/
public void underattack(int aAttackPoint) {
int totalHp;
totalHp = unitHp + unitShield;
totalHp -= aAttackPoint;
if (totalHp > unitHp) {
unitShield = totalHp - unitHp;
System.out.println("공격받�후� Dragoon� Hp와 Shield");
System.out.print(unitHp);
System.out.print(unitShield);
} else if (totalHp == unitHp) {
unitShield = 0;
System.out.println("공격받�후� Dragoon� Hp와 Shield");
System.out.print(unitHp);
System.out.print(unitShield);
} else {
unitHp = totalHp;
System.out.println("공격받�후� Dragoon� Hp와 Shield");
System.out.print(unitHp);
System.out.print(unitShield);
}
}
public int getAttackPoint() {
return attackPoint;
}
public int getHp() {
return unitHp;
}
public int getShield() {
return unitShield;
}
public static void main(String[] args) {
zealot z = new zealot(100, 100, 10, "attack", false);
dragoon d = new dragoon(150, 150, 20, "stop", true);
System.out.println("ê³µê²©ë°›ê¸°ì „ì�˜ Dragoonì�˜ Hp와 Shield");
System.out.println(d.getHp());
System.out.println(d.getShield());
d.underattack(z.getAttackPoint());
}
}
zealot ¶
~cpp
public class zealot extends Unit {
public zealot(int hp, int shield, int attack, String state, boolean air) {
super(hp, shield, attack, state, air);
System.out.println("Zealot� �성�었습니다.");
}
}
dragoon ¶
~cpp
public class dragoon extends Unit {
public dragoon(int hp, int shield, int attack, String state, boolean air) {
super(hp, shield, attack, state, air);
System.out.println("Dragoon� �성�었습니다.");
}
}
ì§€ì �í•˜ì‹œê³ ì‹¶ìœ¼ì‹ ë¶€ë¶„ ì�¨ì£¼ì„¸ìš” ^^;
- ì—시 ê¹”ë�”í•˜ê³ ë³´ê³ ì‰¬ìš´ 소스 네요
아쉬운 ì �ì�€, 공격받았ì�„때 실드 깎ì�´ê³ hpê¹�ì�´ëŠ” ì„¤ì •, 사실 ì�´ê±´ 별 ìƒ�ê´€ì—†ê³ ìš”,
ìž�ì‹� í�´ëž˜ìФì�˜ ìƒ�성ìž�는 ì „ë‹¬ì�¸ìž�ê°€ 없는 기본 ìƒ�성ìž� 모양으로 í•´ë†“ê³ ( ex) zealot() )
ìƒ�성ìž� ë‚´ì—�서 ìž�ë�™ìœ¼ë¡œ (질럿ì�´ë‚˜ 드ë�¼êµ°ì�€ hp 실드 등ì�´ ê²°ì •ë�˜ì–´ìžˆìœ¼ë¯€ë¡œ) ê²°ì •í•˜ë©´ ë�” ì¢‹ê² ì£ ? --iruril










