package classes; import java.util.ArrayList; import Interfaces.ComparableObject; import ui.model.iDCounter; public abstract class CpsObject implements ComparableObject { /* Type of the Object */ String objName; /* Name given by the user */ String name; /* ID of the Obj. */ int id; /* Path of the image for the Obj. */ String image; /* Array of neighbors */ ArrayList connectedTo; /* Position with a X and Y value */ Position position; /* Energy input and output of each object in the grid */ float energyIn; float energyOut; /** * Constructor for an CpsObejct with an unique ID */ public CpsObject(String objName) { this.objName = objName; this.name = objName; connectedTo = new ArrayList(); position = new Position(); id = iDCounter.nextId(); image = "/Images/Dummy_House.png"; // System.out.println("ID: " + id + " of " + objName); } public CpsObject(CpsObject obj) { this.objName = obj.getObjName(); connectedTo = new ArrayList(); position = new Position(); id = iDCounter.nextId(); this.name = obj.getName(); this.energyIn = obj.getEnergyIn(); this.energyOut = obj.getEnergyOut(); this.image = obj.getImage(); } /* Obj type */ public String getObjName() { return objName; } public void setObjName(String objName) { this.objName = objName; } /* User defined Name */ public String getName() { return name; } public void setName(String name) { this.name = name; } /* Unique ID number */ public int getID() { return id; } /* Image path */ public String getImage() { return image; } public void setImage(String image) { this.image = image; } /* Neighbors array */ public ArrayList getConnectedTo() { return connectedTo; } public void AddConnection(CpsObject toConnect) { connectedTo.add(toConnect); } /* Position (x and Y) */ public void setPos(int x, int y) { position.x = x; position.y = y; } public Position getPos() { return position; } /* Getter and Setters for the energy input and output */ public float getEnergyIn() { return energyIn; } public void setEnergyIn(float energyIn) { this.energyIn = energyIn; } public float getEnergyOut() { return energyOut; } public void setEnergyOut(float energyOut) { this.energyOut = energyOut; } @Override public String getCompareName() { return objName; } }