Ver código fonte

Remane of classes, add attribute and merge WireNode into HolonObject. This merge implies a change in the heredity hirarchy. HolonSwitch and HolonTransformer inherited from HolonObject.

Edgardo Palza 8 anos atrás
pai
commit
8d9648df93

BIN
bin/tests/Tests1.class


BIN
bin/ui/controller/Building.class


BIN
bin/ui/controller/Gadget.class


BIN
bin/ui/controller/Switch.class


BIN
bin/ui/controller/Transformer.class


BIN
bin/ui/controller/WireNode.class


BIN
bin/ui/controller/cpsObj.class


BIN
bin/ui/view/GUI$1.class


BIN
bin/ui/view/GUI$2.class


+ 5 - 5
src/tests/Tests1.java

@@ -12,10 +12,10 @@ public class Tests1 {
 	 * Create some CPS object and Gadgets
 	 */
 	public static void main(String[] args) {
-		Building b1 = new Building();
-		Building b2 = new Building();
-		Switch s1 = new Switch();
-		Transformer t1 = new Transformer();
-		Gadget g1 = new Gadget();
+		HolonObject b1 = new HolonObject();
+		HolonObject b2 = new HolonObject();
+		HolonSwitch s1 = new HolonSwitch();
+		HolonTransformer t1 = new HolonTransformer();
+		HolonElement g1 = new HolonElement();
 	}
 }

+ 30 - 5
src/ui/controller/CPSObj.java → src/ui/controller/CpsObject.java

@@ -1,6 +1,6 @@
 package ui.controller;
 
-abstract class CPSObj {
+abstract class CpsObject {
 	/* Type of the Object */
 	String objName;
 	/* Name given by the user */
@@ -10,13 +10,21 @@ abstract class CPSObj {
 	/* Path of the image for the Obj. */
 	String image;
 	/* Array of neighbors */
-	CPSObj[] connectedTo;
+	CpsObject[] connectedTo;
 	/* Position with a X and Y value */
 	int xCoord;
 	int yCoord;
-	public CPSObj() {
+	/*Energy input and output of each object in the grid*/
+	float energyIn;
+	float energyOut;
+	
+	/**
+	 * Constructor for an CpsObejct with an unique ID
+	 */
+	public CpsObject() {
 		ID = IdCounter.nextId();
 	}
+	
 	/* Obj type */
 	public String getObjName() {
 		return objName;
@@ -50,11 +58,11 @@ abstract class CPSObj {
 	}
 
 	/* Neighbors array */
-	public CPSObj[] getConnectedTo() {
+	public CpsObject[] getConnectedTo() {
 		return connectedTo;
 	}
 
-	public void setConnectedTo(CPSObj[] connectedTo) {
+	public void setConnectedTo(CpsObject[] connectedTo) {
 		this.connectedTo = connectedTo;
 	}
 
@@ -74,5 +82,22 @@ abstract class CPSObj {
 	public void setyCoord(int yCoord) {
 		this.yCoord = yCoord;
 	}
+	
+	/*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;
+	}
 
 }

+ 2 - 2
src/ui/controller/Gadget.java → src/ui/controller/HolonElement.java

@@ -1,6 +1,6 @@
 package ui.controller;
 
-public class Gadget {
+public class HolonElement {
 
 	/* Name of the gadget */
 	String name;
@@ -13,7 +13,7 @@ public class Gadget {
 	/* Total Energy */
 	float totalEnergy;
 
-	public Gadget() {
+	public HolonElement() {
 		setName("TV");
 		setAmount(1);
 		setEnergy(10);

+ 4 - 4
src/ui/controller/Building.java → src/ui/controller/HolonObject.java

@@ -1,11 +1,11 @@
 package ui.controller;
 
-public class Building extends CPSObj {
+public class HolonObject extends CpsObject {
 	
 	/*Array of all consumers*/
-	Gadget[] consumers;
+	HolonElement[] consumers;
 	/*Array of all producers*/
-	Gadget[] producers;
+	HolonElement[] producers;
 	/*Total of consumption*/
 	float currentEnergy;
 	/**
@@ -20,7 +20,7 @@ public class Building extends CPSObj {
 	 * Constructor
 	 * Set by default the name of the object equals to the category name, until the user changes it.
 	 */
-	public Building() {
+	public HolonObject() {
 		super.setObjName("House");
 		super.name = super.getObjName();
 		System.out.println("You create a " + super.objName + " with ID " + super.ID);

+ 2 - 2
src/ui/controller/Switch.java → src/ui/controller/HolonSwitch.java

@@ -1,10 +1,10 @@
 package ui.controller;
 
-public class Switch extends WireNode {
+public class HolonSwitch extends CpsObject {
 	/*True, if this wire is working (capable of carrying electricity), else false*/
 	boolean isWorking;
 
-	public Switch() {
+	public HolonSwitch() {
 		super.setObjName("Switch");
 		super.name = super.getObjName();
 		System.out.println("You create a " + super.objName + " with ID " + super.ID);

+ 2 - 2
src/ui/controller/Transformer.java → src/ui/controller/HolonTransformer.java

@@ -1,6 +1,6 @@
 package ui.controller;
 
-public class Transformer extends WireNode {
+public class HolonTransformer extends CpsObject {
 
 	/* Ratio of the transformer */
 	float transformRatio;
@@ -9,7 +9,7 @@ public class Transformer extends WireNode {
 	 * Constructor Set type of object (Transformer), its transform ratio and the
 	 * default name ("Transformer");
 	 */
-	public Transformer() {
+	public HolonTransformer() {
 		super.setObjName("Transformer");
 		setTransformRatio(100);
 		super.name = super.getObjName();

+ 0 - 25
src/ui/controller/WireNode.java

@@ -1,25 +0,0 @@
-package ui.controller;
-
-abstract class WireNode extends CPSObj {
-	
-	/**Input capacity of the WireNode.
-	 * For switches  = ??;
-	 * For transformer = ??;
-	 */
-	float energyIn;
-	
-	/**Input capacity of the WireNode.
-	 * For switches  = ??;
-	 * For transformer = ??;
-	 */
-	float energyOut;
-	
-	/**
-	 * Constructor
-	 * Set by default the name of the object equals to the category name, until the user changes it. 
-	 */
-	
-	/**
-	 * Double inheritance for WireNodes? Or should we treat them as a normal class, like Buildings?
-	 */
-}