Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ====================================================tester===================================================
- package tester;
- import pcStore.*;
- public class tester
- {
- public static void main(String[] args)
- {
- Worker[] worker = new Worker[5];
- Computer[] pc = new Computer[10];
- int j =0;
- for (int i = 0; i < worker.length; i++)
- {
- worker[i]= new Worker("worker"+i, i);
- pc[j]=worker[i].buildComputer(i, i, i, i,"i"+j, true);
- pc[j+=1]=worker[i].buildComputer(i, i, i, i,"i"+j, true);
- j+=1;
- }
- for (int i = 0; i < worker.length; i++) {
- System.out.println(worker[i]);
- }
- for (int i = 0; i < pc.length; i++) {
- System.out.println(pc[i]+"\n-------------------------------\n");
- }
- worker[1].buildComputer(10, 10, 10, 10, "i6", true);
- System.out.println(worker[1]);
- System.out.println(worker[1].getTotalComputerBuild());
- System.out.println(worker[4].listReadyComputers());
- System.out.println(worker[4].listMotherBoardUsed());
- worker[2].putCpu(2, "i7");
- System.out.pr
- intln(worker[4].listCpuUsed());
- }
- }
- ===============================================class Computer=================================================================
- package pcStore;
- public class Computer implements computerable,figuresable {
- private int _hdSize,_memorySize,_cpuSpeed,_workerNumber;
- private static int _ReadyComputers,_MemoryUsed,_CpuUsed,_BoardUsed,_HdUse;
- private String _cpuType;
- private boolean _motherBoard;
- public Computer(){}
- public Computer (int hdSize,int memorySize,int cpuSpeed,int workerNumber,String cpuType,boolean motherBoard)
- {
- this.buildBy(workerNumber);
- this.putCpu(cpuSpeed, cpuType);
- this.putHd(hdSize);
- this.putMemory(memorySize);
- this.putMotherBoard(motherBoard);
- _ReadyComputers++;
- }
- public void putHd(int hdSize)
- {
- this._hdSize=hdSize;
- _HdUse++;
- }
- public void putMemory(int memorySize)
- {
- this._memorySize=memorySize;
- _MemoryUsed++;
- }
- public void putCpu(int cpuSpeed, String cpuType)
- {
- this._cpuType=cpuType;
- this._cpuSpeed=cpuSpeed;
- _CpuUsed++;
- }
- public void putMotherBoard(boolean isIntegreated)
- {
- this._motherBoard=true;
- _BoardUsed++;
- }
- public void buildBy (int workerNumber)
- {
- this._workerNumber=workerNumber;
- }
- public String toString()
- {
- return "worker number : "+_workerNumber+"\nhdSize : "+_hdSize+
- "\nmemorySize : "+_memorySize+"\ncpuSpeed : "+_cpuSpeed+
- "\ncpuType : "+_cpuType;
- }
- public int listReadyComputers()
- {
- return _ReadyComputers;
- }
- public int listMemoryUsed()
- {
- return _MemoryUsed;
- }
- public int listCpuUsed()
- {
- return _CpuUsed;
- }
- public int listMotherBoardUsed()
- {
- return _BoardUsed;
- }
- }
- ====================================================class Worker=====================================================
- package pcStore;
- public class Worker extends Computer implements workerable {
- private int _cell;
- private int _ReadyComputersWorker;
- private String _name;
- public Worker(String name,int cell)
- {
- super();
- this._name=name;
- this._cell=cell;
- }
- public Computer buildComputer(int hdSize,int memorySize,int cpuSpeed,int workerNumber,String cpuType,boolean motherBoard)
- {
- _ReadyComputersWorker++;
- return new Computer(hdSize, memorySize, cpuSpeed, workerNumber, cpuType, motherBoard);
- }
- public Worker addNewWorker(String workerName,int workerCell)
- {
- return new Worker(workerName,workerCell);
- }
- public int getTotalComputerBuild()
- {
- return _ReadyComputersWorker;
- }
- public String toString()
- {
- return "name : "+this._name+"\nphone number : "+_cell+"\nnumber of computer he has build : "+this.getTotalComputerBuild();
- }
- }
- =======================================================interface computerable===================================================
- package pcStore;
- public interface computerable {
- void putHd(int hdSize);
- void putMemory(int memorySize);
- void putCpu(int cpuSpeed, String puType);
- void putMotherBoard(boolean isIntegreated);
- void buildBy (int workerNumber);
- String toString();
- }
- ==================================interface workerable====================================
- package pcStore;
- public interface workerable {
- Worker addNewWorker(String workerName,int workerCell);
- int getTotalComputerBuild();
- }
- ==================================interface figuresable=========================================
- package pcStore;
- public interface figuresable {
- int listReadyComputers();
- int listMemoryUsed();
- int listCpuUsed();
- int listMotherBoardUsed();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement