CpsObject.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package ui.model;
  2. import java.util.ArrayList;
  3. abstract class CpsObject {
  4. /* Type of the Object */
  5. String objName;
  6. /* Name given by the user */
  7. String name;
  8. /* ID of the Obj. */
  9. int id;
  10. /* Path of the image for the Obj. */
  11. String image;
  12. /* Array of neighbors */
  13. ArrayList<CpsObject> connectedTo;
  14. /* Position with a X and Y value */
  15. Position position;
  16. /*Energy input and output of each object in the grid*/
  17. float energyIn;
  18. float energyOut;
  19. /**
  20. * Constructor for an CpsObejct with an unique ID
  21. */
  22. public CpsObject(String objName) {
  23. this.objName = objName;
  24. connectedTo = new ArrayList<CpsObject>();
  25. position = new Position();
  26. }
  27. /* Obj type */
  28. public String getObjName() {
  29. return objName;
  30. }
  31. public void setObjName(String objName) {
  32. this.objName = objName;
  33. }
  34. /* User defined Name */
  35. public String getName() {
  36. return name;
  37. }
  38. public void setName(String name) {
  39. this.name = name;
  40. }
  41. /* Unique ID number */
  42. public int getID() {
  43. return id;
  44. }
  45. /* Image path */
  46. public String getImage() {
  47. return image;
  48. }
  49. public void setImage(String image) {
  50. this.image = image;
  51. }
  52. /* Neighbors array */
  53. public ArrayList<CpsObject> getConnectedTo() {
  54. return connectedTo;
  55. }
  56. public void AddConnection(CpsObject toConnect) {
  57. connectedTo.add(toConnect);
  58. }
  59. /* Position (x and Y) */
  60. public void setPos(int x, int y){
  61. position.x = x;
  62. position.y = y;
  63. }
  64. public Position getPos(){
  65. return position;
  66. }
  67. /*Getter and Setters for the energy input and output*/
  68. public float getEnergyIn() {
  69. return energyIn;
  70. }
  71. public void setEnergyIn(float energyIn) {
  72. this.energyIn = energyIn;
  73. }
  74. public float getEnergyOut() {
  75. return energyOut;
  76. }
  77. public void setEnergyOut(float energyOut) {
  78. this.energyOut = energyOut;
  79. }
  80. }