U E D R , A S I H C RSS

Java Study2004/이승한

숙제


1.1. person

~cpp 
public class person {
	private String name;
	private boolean state; // true study	
	
	public person( String Aname ){
		name = Aname;
		state = true;
	}
	
	public void sayName(){
		System.out.println("name");
	}
	
	public void showState(){
		if( state ){
			System.out.println("study");
		}else System.out.println("rest");
	}
	
	public void toRest(){
		state = false;
		this.showState();
	}
	
	public void toStudy(){
		state = true;
		this.showState();
	}
	
	public static void main( String args [] ){
		person LSH = new person("lee seung han");
		LSH.toStudy();			
	}
}

1.2. STAR

1.2.1. Main class

메인만 있는 클래스를 만들어 C처럼 해보았더니 저는 인해하기가 한결 수월하더군요.
공격을 받는 유닛이 공격을 하는 유닛의 공격력을 돌려받는 함수 호출합니다.
공격력을 돌려주는 함수는 공격하는 유닛의 속성을 공격상태로 바꾸어 줍니다.
~cpp 
public class Main {
	//메인 클래스를 따로 만드는 것도 코드를 읽기에는 상당히 편할것 같습니다.
	public static void main(String[] args) {
		Zelot partyZelot = new Zelot();
		Dragon partyDragon = new Dragon();
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );	
		partyDragon.attaced( partyZelot.attac() );	
		partyDragon.attaced( partyZelot.attac() );	
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );	
		partyDragon.attaced( partyZelot.attac() );	
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
		partyDragon.attaced( partyZelot.attac() );
	}
}

1.2.2. Unit class

대부분의 유닛의 행동과 속성들은 여기에 들어 있습니다.
쉴드는 HP에 포함시키도록 만들었습니다.
~cpp 
public class Unit {
	//멤버 변수들
	protected int force; //생산된 진영
	protected int hp;
	protected int attacRating;
	protected int state; //1공격, 2홀드, 3무브, 4스탑
	protected boolean possibleAirAttac; //공중 공격 가능여부
	
	//생성자
	public Unit(){
		force = 1;
		hp = 1;
		attacRating = 0;
		state = 4;
		possibleAirAttac = false; 
	}
	public Unit(int aForce, int aHp, int aAttacRating, int aState, boolean aPossibleAirAttac ){
		force = aForce;
		hp = aHp;
		attacRating = aAttacRating;
		state = aState;
		possibleAirAttac = aPossibleAirAttac;
	}
	
	//멤버 함수
	//공격을 받는다.
	public boolean attaced( int AattacRating ){
		if( hp > 0 ){
		hp -= AattacRating;
		System.out.println(hp);
		if( hp > 0){
			return true;
		}else{
			System.out.println("die.");
			return false;
		}
		}else {
			System.out.println("dead.");
			return false;
		}
	}
	
	protected int attac( ){
		state = 1; //공격
		return attacRating;
	}

	protected void shiled( int Ashiled ){
		hp+= Ashiled;
	}
}

1.2.3. dragon

dragon은 스펠링이 dragoon 이더군요...-0-
~cpp 
public class Dragon extends Unit{
	//생성자 입니다.
	public Dragon(){
		super(1, 100, 10, 4, false);
		setUnit( 1 );
	}
	public Dragon(int aForce){
		super(aForce, 100, 10, 4, true);
	}
	public void setUnit( int aForce ){
		shiled ( 150 );
		System.out.println("I am returned.");
	}
}

1.2.4. zelot

zelot도 zealot 이고요...-0-
~cpp 
public class Zelot extends Unit{
	//생성자 입니다.
	public Zelot(){
		super(1, 100, 10, 4, false);
		shiled( 100 );
		System.out.println("My Life for Aiur...");
	}
}
  • 깔끔하고 알아보기 쉬운 소스네요 흠 아닌 흠이라면 실드깎이고 hp깎이는거 정도? 참 잘했어요~. --iruril

2. Thread

공부와 휴식만 하는 성실한 학생을 만들었구나. 꼭 나 같어 ㅎㅎ --강희경
사실 모델은 나였어 --iruril

프로토스 유닛의 경우 쉴드가 있습니다. 실제 스타 게임의 경우 hp, 쉴드 만땅이 100, 100이라고 생각하면 총 life가 200을 넘는 경우가 나오지 않겠죠? 또 공격을 당해 쉴드가 다 깍이고 체력까지 당해서 50, 0이 된 경우 아무리 쉴드가 복구 된다고 해도 총 life가 150을 넘는 경우는 없겠죠? 제 생각엔 쉴드와 hp를 따로 관리하는 것이 좋겠네요. 노수민 선생님이 내주신 숙제에도 그렇게 정리가 되어 있습니다. 그리고 질럿과 드라군의 hp와 공격력이 같네요. --교장

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:32
Processing time 0.0131 sec