Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ****************************************************************************************************
- import Testers.* ;
- import java.util.ArrayList;
- import Testers.Computer;
- import Testers.ComputersList;
- import Testers.Worker;
- public class ComputerCompanyTester {
- public static void main(String[] args)
- {
- ArrayList<Computer> Computers=new ArrayList<Computer>(10) ;
- ArrayList<Worker> Workers=new ArrayList<Worker>(5) ;
- try
- {
- for(Computer Com :Computers)
- {
- Com=new Computer(500, 4, 2000, "I5" , true ,12345);
- }
- for(Worker WorkerTmp :Workers)
- {
- WorkerTmp=new Worker("Ayob" ,2222 ,"054-2204516") ;
- }
- }
- catch(Exception e)
- {
- System.out.println(e.getMessage());
- }
- ComputersList ComputerListTest=new ComputersList(Computers,Workers);
- ComputerListTest.ListComputers();
- ComputerListTest.ListCpuUsed();
- ComputerListTest.ListHdUsed();
- ComputerListTest. ListMemoryUsed();
- // Add New Worker to Worker List
- Worker newWorker=new Worker("Nati",4444,"04-4567890");
- ComputerListTest. AddWorker(newWorker);
- }
- }
- package Testers;
- public interface ComputerAssembly
- {
- void putHD(int HdSize);
- void putMemory(int MemorySize) ;
- void putCpu(int Speed ,String Type);
- void putMotherBoard(boolean isIntegrated );
- String toString() ;
- }
- ****************************************************************************************************
- public class Computer implements ComputerAssembly
- { static int Counter ;
- int HdSize ;
- int MemorySize ;
- int CpuSpeed ;
- String CpuType ;
- boolean MotherBoardIsintegrated ;
- int WorkerID ;
- public Computer() { Counter++; }
- public Computer(int hdSize, int memorySize, int cpuSpeed, String cpuType, boolean motherBoard,int Workerid) {
- super();
- Counter++ ;
- HdSize = hdSize;
- MemorySize = memorySize;
- CpuSpeed = cpuSpeed;
- CpuType = cpuType;
- MotherBoardIsintegrated = motherBoard;
- WorkerID=Workerid ;
- }
- public void putHD(int HdSize) {
- this.HdSize=HdSize ;
- }
- public void putMemory(int MemorySize) {
- this.MemorySize=MemorySize ;
- }
- public void putCpu(int Speed, String Type) {
- this.CpuSpeed=Speed ;
- this.CpuType=Type ;
- }
- public void putMotherBoard(boolean isIntegrated) {
- this.MotherBoardIsintegrated=isIntegrated ;
- }
- public String getMotherBoard()
- {
- return (MotherBoardIsintegrated==true? "Integrated ": "Not Integrated") ;
- }
- void BuildBy(int WorkerID)
- {
- this.WorkerID=WorkerID ;
- }
- public String toString ()
- {
- return "Computer Number: " + Counter + "Build By Worker Number : " + WorkerID +" HD Sise : " +HdSize + "MermorySize : "+ MemorySize
- +" CPU Speed : " +CpuSpeed + "CPU Type : "+ CpuType +" MotherBoard is " +(MotherBoardIsintegrated==true? "Integrated ": "Not Integrated");
- }
- public int getHdSize() {
- return HdSize;
- }
- public void setHdSize(int hdSize) {
- HdSize = hdSize;
- }
- public int getMemorySize() {
- return MemorySize;
- }
- public void setMemorySize(int memorySize) {
- MemorySize = memorySize;
- }
- public int getCpuSpeed() {
- return CpuSpeed;
- }
- public void setCpuSpeed(int cpuSpeed) {
- CpuSpeed = cpuSpeed;
- }
- public String getCpuType() {
- return CpuType;
- }
- public void setCpuType(String cpuType) {
- CpuType = cpuType;
- }
- }
- ****************************************************************************************************
- package Testers;
- public class Worker
- {
- static int Counter ;
- int workerID ;
- String Name ;
- String Cell ;
- Worker(){Counter++; }
- public Worker (String name , int id , String cell)
- {
- Counter++;
- this.Name=name ;
- this.workerID=id ;
- this.Cell=cell;
- }
- public String getName ()
- { return Name; }
- public void setName(String Name)
- { this.Name=Name ; }
- public int getWorkerID() {
- return workerID;
- }
- public void setWorkerID(int workerID) {
- this.workerID = workerID;
- }
- public String getCell() {
- return Cell;
- }
- public void setCell(String cell) {
- Cell = cell;
- }
- }
- ****************************************************************************************************
- package Testers;
- import java.util.ArrayList;
- public class ComputersList
- {
- ArrayList<Computer> Computers ;
- ArrayList<Worker> Workers ;
- ComputersList() {}
- public ComputersList(ArrayList<Computer> Computers, ArrayList<Worker> Workers)
- {
- this.Computers=Computers ;
- this.Workers=Workers ;
- }
- public int GetTotalComputers()
- {
- return this.Computers.size() ;
- }
- public void ListComputers( )
- {
- for(Computer computer:Computers)
- {
- computer.toString();
- System.out.println("\n");
- }
- }
- public void ListMemoryUsed( )
- {
- for(Computer computer:Computers)
- {
- System.out.println("\n "+ computer.getMemorySize());
- }
- }
- public void ListCpuUsed( )
- {
- for(Computer computer:Computers)
- {
- System.out.println("\n "+ computer.getCpuSpeed()+ "Cpu Type : "+ computer.getCpuType());
- }
- }
- public void ListHdUsed( )
- {
- for(Computer computer:Computers)
- {
- System.out.println("\n "+ computer.getHdSize());
- }
- }
- public void AddWorker( Worker NewWorker)
- {
- Workers.add(NewWorker);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement