public abstract class AbstractFatory {
public abstract Vehicle createVehicle();
public abstract Weapon createWeapon();
public abstract food createFood();
}
public class DefaultFactory extends AbstractFatory{
@Override
public Vehicle createVehicle() {
return new Car();
}
@Override
public Weapon createWeapon() {
return new AK47();
}
@Override
public food createFood() {
return new Apple();
}
}
public class MagicFactory extends AbstractFatory{
@Override
public Vehicle createVehicle() {
return new Car();
}
@Override
public Weapon createWeapon() {
return new Gun();
}
@Override
public food createFood() {
return new Apple();
}
}
public class Apple extends food{
@Override
public void print() {
System.out.println("apple");
}
}
public class AK47 extends Weapon{
@Override
public void shoot(){
System.out.println("shoot.....");
}
}