public class Stock1 { public void Buy(){ System.out.println("股票一买入"); } public void Sell(){ System.out.println("股票一卖出"); }}public class Stock2 { public void Buy(){ System.out.println("股票二买入"); } public void Sell(){ System.out.println("股票二卖出"); }}public class Stock3 { public void Buy(){ System.out.println("股票三买入"); } public void Sell(){ System.out.println("股票三卖出"); }}public class Fund { Stock1 stock1; Stock2 stock2; Stock3 stock3; public Fund(){ stock1 = new Stock1(); stock2 = new Stock2(); stock3 = new Stock3(); } public void Buy(){ stock1.Buy(); stock2.Buy(); stock3.Buy(); } public void Sell(){ stock1.Sell(); stock2.Sell(); stock3.Sell(); }}public class Test { public static void main(String[] args) { Fund fund = new Fund(); fund.Buy(); fund.Sell(); }}