Browse Source

Class Gadget: Fix some variables and add the function totalEnergy
Some example/useless clases eliminated

Edgardo Palza 8 years ago
parent
commit
b889e0443f

BIN
bin/tests/Tests1.class


BIN
bin/ui/controller/AboutWindow.class


BIN
bin/ui/controller/Gadget.class


BIN
bin/ui/controller/WireNode.class


+ 0 - 3
src/tests/Tests1.java

@@ -17,8 +17,5 @@ public class Tests1 {
 		System.out.println(b1.getName());
 		Buildings b2 = new Buildings();
 		System.out.println(b2.getID());
-		WireNode w1 = new WireNode();
-		System.out.println(w1.getName());
-		System.out.println(w1.getID());
 	}
 }

+ 0 - 10
src/ui/controller/AboutWindow.java

@@ -1,10 +0,0 @@
-package ui.controller;
-
-/**
- * Authors' names and credits
- *
- */
-
-public class AboutWindow {
-
-}

+ 27 - 10
src/ui/controller/Gadget.java

@@ -1,24 +1,24 @@
 package ui.controller;
 
 public class Gadget {
-	
-	/*Name of the gadget*/
+
+	/* Name of the gadget */
 	String name;
-	/*Quantity*/
+	/* Quantity */
 	int amount;
-	/*Energy per gadget*/
+	/* Energy per gadget */
 	float energy;
-	/*If the gadget is working xor not (true xor false)*/
+	/* If the gadget is working xor not (true xor false) */
 	boolean isWorking;
-	/*Total Energy*/
+	/* Total Energy */
 	float totalEnergy;
-	
+
 	public Gadget() {
 		setName("TV");
 		setAmount(1);
 		setEnergy(10);
 		this.isWorking = true;
-		this.totalEnergy = energy*amount;
+		this.totalEnergy = getTotalEnergy();
 	}
 
 	public String getName() {
@@ -44,6 +44,23 @@ public class Gadget {
 	public void setEnergy(float energy) {
 		this.energy = energy;
 	}
-	
-	
+
+	public void switchGadget(boolean bool) {
+		this.isWorking = bool;
+	}
+
+	public boolean getState() {
+		return isWorking;
+	}
+
+	/**
+	 * Multiply the amount of gadgets, given by the user, and the
+	 * consumption/production. If the switch isWorking is turned off for on
+	 * gadget, the energy of this gadget have to be subtracted
+	 * 
+	 * @return totalEnergy (actual)
+	 */
+	public float getTotalEnergy() {
+		return 0;
+	}
 }

+ 8 - 5
src/ui/controller/WireNode.java

@@ -1,6 +1,6 @@
 package ui.controller;
 
-public class WireNode extends CPSObj {
+abstract class WireNode extends CPSObj {
 	
 	/**Input capacity of the WireNode.
 	 * For switches  = ??;
@@ -19,8 +19,11 @@ public class WireNode extends CPSObj {
 	 * Set by default the name of the object equals to the category name, until the user changes it. 
 	 */
 	
-	public WireNode() {
-		super.setObjName("Switch");
-		super.name = super.getObjName();
-	}
+	/**
+	 * Double inheritance for WireNodes? Or should we treat them as a normal class, like Buildings?
+	 */
+//	public WireNode() {
+//  	super.setObjName("Switch");
+//		super.name = super.getObjName();
+//	}
 }