本帖最后由 mohuancaizi 于 2014-3-12 08:03 编辑
- class MainBoard{
- public void run(){
- System.out.println("mainboard run");
- }
- public void useNetCard(Netcard c){
- c.open();
- c.close();
- }
- }
-
- class Netcard{
- public void open(){
- System.out.println("netcard open");
- }
- public void close(){
- System.out.println("netcard close");
- }
-
-
- }
-
- class duotai3computer {
-
- public static void main(String[] args) {
- MainBoard mb = MainBoard();
- mb.run();
- mb.useNetCard(new Netcard());
- }
-
- }
复制代码 |
|