package org.ustc.facade;
public class Fund {
private NationDebt dn;
private Realty realty;
private Stock stock;
public Fund() {
dn = new NationDebt();
realty = new Realty();
stock = new Stock();
}
public void buy(){
dn.buy();
realty.buy();
stock.buy();
}
public void sell(){
dn.sell();
realty.sell();
stock.sell();
}
}
package org.ustc.facade;
public class NationDebt {
public void buy(){
System.out.println("购买国债");
}
public void sell(){
System.out.println("卖出国债");
}
}
package org.ustc.facade;
public class Realty {
public void buy(){
System.out.println("购买了房地产");
}
public void sell(){
System.out.println("卖出房产");
}
}
package org.ustc.facade;
public class Stock {
public void buy(){
System.out.println("购买股票");
}
public void sell(){
System.out.println("卖出股票");
}
}
package org.ustc.facade;
public class Main {
public static void main(String[] args) {
Fund fund = new Fund();
fund.buy();
fund.sell();
}
}