zoukankan      html  css  js  c++  java
  • Test类实验

    package PC_TEST;
    
    class CPU{
    	int speed;
    	CPU(){
    		speed=0;
    	}
    	CPU(int k){
    		speed=k;
    	}
    	void setSpeed(int k){
    		speed=k;
    	}
    	int setSpeed(){
    		return speed;
    	}
    }
    
    class HardDisk{
    	int amount;
    	HardDisk(){
    		amount=0;
    	}
    	HardDisk(int k){
    		amount=k;
    	}
    	void setSpeed(int k){
    		amount=k;
    	}
    	int setSpeed(){
    		return amount;
    	}
    }
    
    class PC{
    	CPU cpu;
    	HardDisk HD;
    	PC(){
    		cpu=new CPU();
    		HD=new HardDisk();
    	}
    	void setCPU(CPU c){
    		cpu=c;
    	}
    	void setHarDisk(HardDisk h){
    		HD=h;
    	}
    	void show(){
    		System.out.println("CPU speed:"
    				+          +cpu.speed
    						   +" HardDisk amount:"
    						   +HD.amount);
    	}
    }
    
    public class TEST {
    	public static void main(String[] args) {
    		CPU cpu=new CPU(2200);
    		HardDisk disk=new HardDisk(200);
    		PC pc=new PC();
    		pc.setCPU(cpu);
    		pc.setHarDisk(disk);
    		pc.show();
    	}
    }
    


  • 相关阅读:
    记账本开发第一天-补
    20200418-补
    20200411-补
    20200404-补
    20200328-补
    暴力解N皇后
    nN皇后递归
    Hanoi汉诺塔非递归栈解
    Hanoi汉诺塔递归
    JMMjmm模型
  • 原文地址:https://www.cnblogs.com/WALLACE-S-BOOK/p/9732340.html
Copyright © 2011-2022 走看看