Advertisement
Guest User

Ayob-ComputerCompany

a guest
Feb 6th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.53 KB | None | 0 0
  1. ****************************************************************************************************
  2. import Testers.* ;
  3. import java.util.ArrayList;
  4. import Testers.Computer;
  5. import Testers.ComputersList;
  6. import Testers.Worker;
  7. public class ComputerCompanyTester {
  8.  
  9.     public static void main(String[] args)
  10.    
  11.     {
  12.        ArrayList<Computer> Computers=new ArrayList<Computer>(10) ;
  13.         ArrayList<Worker> Workers=new ArrayList<Worker>(5) ;
  14.        
  15.         try
  16.         {  
  17.             for(Computer Com :Computers)
  18.         {
  19.             Com=new Computer(500, 4, 2000, "I5" , true ,12345);
  20.         }
  21.        
  22.         for(Worker WorkerTmp :Workers)
  23.         {
  24.             WorkerTmp=new Worker("Ayob" ,2222 ,"054-2204516") ;
  25.         }
  26.         }
  27.        
  28.  
  29.  
  30.         catch(Exception e)
  31.         {
  32.             System.out.println(e.getMessage());
  33.         }
  34.        
  35.         ComputersList ComputerListTest=new ComputersList(Computers,Workers);
  36.        
  37.         ComputerListTest.ListComputers();
  38.         ComputerListTest.ListCpuUsed();
  39.         ComputerListTest.ListHdUsed();
  40.         ComputerListTest. ListMemoryUsed();
  41.        
  42.         // Add New Worker to Worker List
  43.        
  44.         Worker newWorker=new Worker("Nati",4444,"04-4567890");
  45.        
  46.         ComputerListTest. AddWorker(newWorker);
  47.         }
  48.  
  49. }
  50.  
  51.  
  52.  
  53.  
  54.  
  55. package Testers;
  56.  
  57. public interface ComputerAssembly
  58.  
  59. {
  60.  void putHD(int HdSize);
  61.  void putMemory(int MemorySize) ;
  62.  void putCpu(int Speed ,String Type);
  63.  void putMotherBoard(boolean isIntegrated );
  64.  String toString() ;
  65.  
  66. }
  67.  
  68. ****************************************************************************************************
  69. public class Computer implements ComputerAssembly
  70.  
  71. {    static int Counter ;
  72.      int HdSize ;
  73.      int MemorySize ;
  74.      int CpuSpeed ;
  75.      String CpuType ;
  76.      boolean MotherBoardIsintegrated ;
  77.      int WorkerID  ;
  78.      
  79.     public Computer() { Counter++; }
  80.      
  81.      
  82.      
  83.     public Computer(int hdSize, int memorySize, int cpuSpeed, String cpuType, boolean motherBoard,int Workerid) {
  84.         super();
  85.         Counter++ ;
  86.         HdSize = hdSize;
  87.         MemorySize = memorySize;
  88.         CpuSpeed = cpuSpeed;
  89.         CpuType = cpuType;
  90.         MotherBoardIsintegrated = motherBoard;
  91.         WorkerID=Workerid ;
  92.     }
  93.  
  94.  
  95.  
  96.    
  97.     public void putHD(int HdSize) {
  98.         this.HdSize=HdSize ;
  99.        
  100.     }
  101.  
  102.    
  103.     public void putMemory(int MemorySize) {
  104.          this.MemorySize=MemorySize ;
  105.        
  106.     }
  107.  
  108.    
  109.     public void putCpu(int Speed, String Type) {
  110.         this.CpuSpeed=Speed ;
  111.         this.CpuType=Type ;
  112.        
  113.     }
  114.  
  115.    
  116.     public void putMotherBoard(boolean isIntegrated) {
  117.         this.MotherBoardIsintegrated=isIntegrated ;
  118.        
  119.     }
  120.    
  121.     public String getMotherBoard()
  122.     {
  123.       return (MotherBoardIsintegrated==true? "Integrated ": "Not Integrated") ;
  124.     }
  125.    
  126.     void BuildBy(int WorkerID)
  127.     {
  128.         this.WorkerID=WorkerID ;
  129.     }
  130.  
  131.      public String toString ()
  132.      {
  133.           return "Computer Number: " + Counter + "Build By Worker Number : " + WorkerID +" HD Sise : " +HdSize + "MermorySize : "+ MemorySize
  134.           +" CPU Speed : " +CpuSpeed + "CPU Type : "+ CpuType +" MotherBoard is " +(MotherBoardIsintegrated==true? "Integrated ": "Not Integrated");
  135.            
  136.      }
  137.  
  138.  
  139.  
  140.     public int getHdSize() {
  141.         return HdSize;
  142.     }
  143.  
  144.  
  145.  
  146.     public void setHdSize(int hdSize) {
  147.         HdSize = hdSize;
  148.     }
  149.  
  150.  
  151.  
  152.     public int getMemorySize() {
  153.         return MemorySize;
  154.     }
  155.  
  156.  
  157.  
  158.     public void setMemorySize(int memorySize) {
  159.         MemorySize = memorySize;
  160.     }
  161.  
  162.  
  163.  
  164.     public int getCpuSpeed() {
  165.         return CpuSpeed;
  166.     }
  167.  
  168.  
  169.  
  170.     public void setCpuSpeed(int cpuSpeed) {
  171.         CpuSpeed = cpuSpeed;
  172.     }
  173.  
  174.  
  175.  
  176.     public String getCpuType() {
  177.         return CpuType;
  178.     }
  179.  
  180.  
  181.  
  182.     public void setCpuType(String cpuType) {
  183.         CpuType = cpuType;
  184.     }
  185.      
  186.     }
  187.  
  188. ****************************************************************************************************
  189. package Testers;
  190.  
  191. public class Worker
  192. {
  193.  static int Counter ;
  194.  int workerID ;
  195.  String Name ;
  196.  String Cell ;
  197.  Worker(){Counter++; }
  198.  public Worker (String name , int id , String cell)
  199.  {
  200.      Counter++;
  201.      this.Name=name ;
  202.      this.workerID=id ;
  203.      this.Cell=cell;
  204.      
  205.  }
  206.  
  207.  
  208.  public String getName ()
  209.  { return Name;  }
  210.  
  211. public void setName(String Name)
  212.  {  this.Name=Name ; }
  213. public int getWorkerID() {
  214.     return workerID;
  215. }
  216. public void setWorkerID(int workerID) {
  217.     this.workerID = workerID;
  218. }
  219. public String getCell() {
  220.     return Cell;
  221. }
  222. public void setCell(String cell) {
  223.     Cell = cell;
  224. }
  225.  
  226.  
  227.  
  228. }
  229.  
  230. ****************************************************************************************************
  231. package Testers;
  232. import java.util.ArrayList;
  233. public class ComputersList
  234.  
  235.  {
  236.     ArrayList<Computer> Computers ;
  237.     ArrayList<Worker> Workers ;
  238.  
  239.   ComputersList() {}
  240.  
  241.  public  ComputersList(ArrayList<Computer> Computers, ArrayList<Worker> Workers)
  242.   {
  243.        this.Computers=Computers ;
  244.        this.Workers=Workers ;
  245.   }
  246.  
  247.   public int GetTotalComputers()
  248.   {
  249.       return this.Computers.size() ;
  250.   }
  251.  
  252.   public void ListComputers( )
  253.   {
  254.       for(Computer computer:Computers)
  255.       {
  256.           computer.toString();
  257.           System.out.println("\n");
  258.       }
  259.   }
  260.  
  261.   public void ListMemoryUsed( )
  262.   {
  263.       for(Computer computer:Computers)
  264.       {
  265.          
  266.           System.out.println("\n "+ computer.getMemorySize());
  267.       }
  268.   }
  269.  
  270.   public void ListCpuUsed( )
  271.   {
  272.       for(Computer computer:Computers)
  273.       {
  274.          
  275.           System.out.println("\n "+ computer.getCpuSpeed()+ "Cpu Type : "+ computer.getCpuType());
  276.       }
  277.   }
  278.  
  279.   public void ListHdUsed( )
  280.   {
  281.       for(Computer computer:Computers)
  282.       {
  283.          
  284.           System.out.println("\n "+ computer.getHdSize());
  285.       }
  286.   }
  287.  
  288.   public void AddWorker( Worker NewWorker)
  289.   {
  290.       Workers.add(NewWorker);
  291.   }
  292.  
  293.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement