728x90
public class TestUnit {
public static void main(String[] args) {
} // end of main;
} // end of class;
class Point {
int x;
int y;
}
class Marine extends Unit{ // 보병을 정의한 클래스
void move(Point p) {
System.out.println("마린이 언덕을 돌아감");
}
void stimPack() {
System.out.println("스팀패애애액~~~~~~");
}
}
class Tank extends Unit{ // 탱크에 관한 클래스
void move(Point p) {
System.out.println("탱크가 뒤뚱뒤뚱");
}
void changeMode() {
System.out.println("모드변경 쓍 퉁~~~~~~");
}
}
class Dropship extends Unit{ // 드랍쉽을 정의한 클래스
void move(Point p) {
System.out.println("sdfsdf");
}
void load() {
}
void unload() {
}
}
abstract class Unit{
Point P;
//상속 받은부분에서 move(Point p) 메서드 재정의해야 사용가능하다.
abstract void move(Point p);
//공통적으로 쓸 메서드
void stop(){
System.out.println("정지");
}
}
728x90
반응형
'Java' 카테고리의 다른 글
| Java 인터페이스간 상속 및 다중상속 (1) | 2017.07.13 |
|---|---|
| Java 인터페이스의 설명 및 일반클래스 , 추상클래스 , 인터페이스의 차이점 (0) | 2017.07.13 |
| Java 추상클래스 ( abstract ) 란? (0) | 2017.07.13 |
| Java 다형성 ( polymorphism ) 의 예제(2) (0) | 2017.07.12 |
| Java 다형성 ( polymorphism ) 의 예제(1) (0) | 2017.07.12 |
댓글