package class_abstract_common;
abstract class unit
{
static int x=10;
static int y=20;
abstract void move(int x, int y);
void stop()
{
System.out.println("stop");
};
}
class Tank extends unit
{
@Override
void move(int x, int y) {
// TODO Auto-generated method stub
x=super.x;
y=super.y;
System.out.println("Move to: ( "+x+", "+y+" )");
}
void changeMod()
{
System.out.println("Change the mode");
}
}
public class Marine extends unit{
public static void main(String[] args) {
// TODO Auto-generated method stub
Marine m=new Marine();
m.move(0, 1);
m.stimpack();
System.out.println();
Tank t=new Tank();
t.move(x, y);
t.changeMod();
}
@Override
void move(int x, int y) {
// TODO Auto-generated method stub
System.out.println("Move to: ( "+x+", "+y+" )");
}
void stimpack()
{
System.out.println("use stimpack!");
}
}
Unit[] group=new Unit[2];
unit[0]=new A();
unit[1]=new B();
for(int i=0;i"<"group.length;i++)
{
unit[i].move();
}
Didn't CALL abstract class !!
It calls its own method(override)!!