package domain; import java.io.Serializable; import java.util.Collection; import java.util.HashMap; public class Factory implements Serializable { private HashMap robots = new HashMap<>(); private int c3poID = 0; private int r2d2ID = 1000; public Factory(){ } //Has to return Collection public Collection getRobotList(){ return robots.values(); } public boolean buildNewRobot(String name, int type){ Robot r ; if(type == 0){ r = new R2D2(r2d2ID++, name); }else if(type == 1){ r = new C3PO(c3poID++, name); }else{ return false; } robots.put(r.getId(), r); return true; } }