/**
* 抽象的好处
*/
public class Benifit {
public static void main(String[] args) {
Desk desk = new Desk();
desk.guo = new ShaGuo();
desk.cook();
}
}
class Desk{//一张桌子
public Guo guo;//挖空了一部份,就是抽象的
public void cook(){
guo.cook();
}
}
abstract class Guo{
public abstract void cook();
}
class ShaGuo extends Guo{//砂锅
public void cook() {
System.out.println("砂锅煮东西");
}
}
class TieGuo extends Guo{//砂锅
public void cook() {
System.out.println("铁锅炒东西");
}
}
* 抽象的好处
*/
public class Benifit {
public static void main(String[] args) {
Desk desk = new Desk();
desk.guo = new ShaGuo();
desk.cook();
}
}
class Desk{//一张桌子
public Guo guo;//挖空了一部份,就是抽象的
public void cook(){
guo.cook();
}
}
abstract class Guo{
public abstract void cook();
}
class ShaGuo extends Guo{//砂锅
public void cook() {
System.out.println("砂锅煮东西");
}
}
class TieGuo extends Guo{//砂锅
public void cook() {
System.out.println("铁锅炒东西");
}
}