Advertisement
Guest User

shalty-pcStor

a guest
Feb 6th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.53 KB | None | 0 0
  1.  
  2. ====================================================tester===================================================
  3. package tester;
  4. import pcStore.*;
  5. public class tester
  6. {
  7.     public static void main(String[] args)
  8.     {
  9.     Worker[] worker = new Worker[5];   
  10.     Computer[] pc = new Computer[10];
  11.     int j =0;
  12.      for (int i = 0; i < worker.length; i++)
  13.      {
  14.          worker[i]= new Worker("worker"+i, i);
  15.         pc[j]=worker[i].buildComputer(i, i, i, i,"i"+j, true);
  16.         pc[j+=1]=worker[i].buildComputer(i, i, i, i,"i"+j, true);
  17.         j+=1;
  18.      } 
  19.      for (int i = 0; i < worker.length; i++) {
  20.         System.out.println(worker[i]);
  21.     }
  22.     for (int i = 0; i < pc.length; i++) {
  23.        
  24.         System.out.println(pc[i]+"\n-------------------------------\n");
  25.     }
  26.     worker[1].buildComputer(10, 10, 10, 10, "i6", true);
  27.     System.out.println(worker[1]);
  28.     System.out.println(worker[1].getTotalComputerBuild());
  29.     System.out.println(worker[4].listReadyComputers());
  30.     System.out.println(worker[4].listMotherBoardUsed());
  31.     worker[2].putCpu(2, "i7");
  32.     System.out.pr
  33. intln(worker[4].listCpuUsed());
  34.     }
  35. }
  36. ===============================================class Computer=================================================================
  37.  
  38. package pcStore;
  39.  
  40. public class Computer implements computerable,figuresable {
  41.     private int _hdSize,_memorySize,_cpuSpeed,_workerNumber;
  42.     private static int _ReadyComputers,_MemoryUsed,_CpuUsed,_BoardUsed,_HdUse;
  43.     private String _cpuType;
  44.     private boolean  _motherBoard;
  45.    
  46.     public Computer(){}
  47.     public Computer (int hdSize,int memorySize,int cpuSpeed,int workerNumber,String cpuType,boolean motherBoard)
  48.     {
  49.         this.buildBy(workerNumber);
  50.         this.putCpu(cpuSpeed, cpuType);
  51.         this.putHd(hdSize);
  52.         this.putMemory(memorySize);
  53.         this.putMotherBoard(motherBoard);
  54.         _ReadyComputers++;
  55.     }
  56.     public void putHd(int hdSize)
  57.     {
  58.         this._hdSize=hdSize;
  59.         _HdUse++;
  60.     }
  61.     public void putMemory(int memorySize)
  62.      {
  63.          this._memorySize=memorySize;
  64.         _MemoryUsed++;
  65.      }
  66.     public void putCpu(int cpuSpeed, String cpuType)
  67.     {
  68.         this._cpuType=cpuType;
  69.         this._cpuSpeed=cpuSpeed;
  70.         _CpuUsed++;
  71.     }
  72.     public void putMotherBoard(boolean isIntegreated)
  73.     {
  74.         this._motherBoard=true;
  75.         _BoardUsed++;
  76.     }
  77.     public void buildBy (int workerNumber)
  78.     {
  79.         this._workerNumber=workerNumber;
  80.     }
  81.     public String toString()
  82.     {
  83.         return "worker number : "+_workerNumber+"\nhdSize : "+_hdSize+
  84.                 "\nmemorySize : "+_memorySize+"\ncpuSpeed : "+_cpuSpeed+
  85.                 "\ncpuType : "+_cpuType;
  86.     }
  87.     public int listReadyComputers()
  88.     {
  89.         return _ReadyComputers;
  90.     }
  91.     public int listMemoryUsed()
  92.     {
  93.         return _MemoryUsed;
  94.     }
  95.     public int listCpuUsed()
  96.     {
  97.         return _CpuUsed;
  98.     }
  99.     public int listMotherBoardUsed()
  100.     {
  101.         return _BoardUsed;
  102.     }
  103. }
  104. ====================================================class Worker=====================================================
  105.  
  106. package pcStore;
  107.  
  108. public class Worker extends Computer implements workerable {
  109.     private int _cell;
  110.     private int _ReadyComputersWorker;
  111.     private String _name;
  112.     public Worker(String name,int cell)
  113.     {
  114.         super();
  115.         this._name=name;
  116.         this._cell=cell;
  117.     }
  118.     public Computer buildComputer(int hdSize,int memorySize,int cpuSpeed,int workerNumber,String cpuType,boolean motherBoard)
  119.     {
  120.         _ReadyComputersWorker++;
  121.         return new Computer(hdSize, memorySize, cpuSpeed, workerNumber, cpuType, motherBoard);
  122.     }
  123.     public Worker addNewWorker(String workerName,int workerCell)
  124.     {
  125.         return new Worker(workerName,workerCell);
  126.     }
  127.     public int getTotalComputerBuild()
  128.     {
  129.         return _ReadyComputersWorker;
  130.     }
  131.     public String toString()
  132.     {
  133.         return "name : "+this._name+"\nphone number : "+_cell+"\nnumber of computer he has build : "+this.getTotalComputerBuild();
  134.     }
  135.    
  136.    
  137. }
  138. =======================================================interface computerable===================================================
  139.  
  140. package pcStore;
  141.  
  142. public interface computerable {
  143.    
  144.      void putHd(int hdSize);
  145.      void putMemory(int memorySize);
  146.      void putCpu(int cpuSpeed, String puType);
  147.      void putMotherBoard(boolean isIntegreated);
  148.      void buildBy (int workerNumber);
  149.      String toString();
  150. }
  151. ==================================interface workerable====================================
  152.  
  153. package pcStore;
  154.  
  155. public interface workerable  {
  156.    
  157.     Worker addNewWorker(String workerName,int workerCell);
  158.     int getTotalComputerBuild();
  159. }
  160. ==================================interface figuresable=========================================
  161.  
  162. package pcStore;
  163.  
  164. public interface figuresable {
  165.     int listReadyComputers();
  166.     int listMemoryUsed();
  167.     int listCpuUsed();
  168.     int listMotherBoardUsed();
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement