Teh-Hai Julian Zheng 7 years ago
parent
commit
dffd805676

+ 20 - 0
src/tests/praktikumHolonsTestObjectController.java

@@ -52,7 +52,27 @@ public class praktikumHolonsTestObjectController {
 		controller.addNewElementIntoCategoryObject("Building", "House", "A", 1, -10);
 		for (int i = 2; i < 27; i++) {
 			controller.addNewElementIntoCategoryObject("Building", "House", adapter.generate(i), i, -10);
+			assertTrue("Total Energy does not match",((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House")).getCurrentEnergy() == -1800 + ((i* (i+1)) / 2) * -10);
 			assertTrue("Number of Elements does not Match", ((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House")).getElements().size() == 6+i);
 		}
+		
+		controller.deleteElementInCategory("Building", "House", "B");
+		controller.deleteElementInCategory("Building", "House", "D");
+		controller.deleteElementInCategory("Building", "House", "F");
+		controller.deleteElementInCategory("Building", "House", "G");
+		controller.deleteElementInCategory("Building", "House", "H");
+		controller.deleteElementInCategory("Building", "House", "I");
+		controller.deleteElementInCategory("Building", "House", "Z");
+		controller.deleteElementInCategory("Building", "House", "TV");
+		assertTrue("Element:B was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "B") == null);
+		assertTrue("Element:D was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "D") == null);
+		assertTrue("Element:F was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "F") == null);
+		assertTrue("Element:G was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "G") == null);
+		assertTrue("Element:H was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "H") == null);
+		assertTrue("Element:I was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "I") == null);
+		assertTrue("Element:Z was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "Z") == null);
+		assertTrue("Element:TV was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "TV") == null);
 	}
+	
+	
 }

+ 3 - 3
src/ui/controller/ObjectController.java

@@ -107,7 +107,7 @@ public class ObjectController {
 		obj.getEleIdx().remove(ele.getEleName());
 		obj.getElements().remove(ele);
 	}
-	
+
 	/**
 	 * deletes a selectedObject
 	 * 
@@ -116,7 +116,7 @@ public class ObjectController {
 	public void deleteSelectedObject(CpsObject obj) {
 		MODEL.getSelectedCpsObjects().remove(obj);
 	}
-	
+
 	/**
 	 * adds a selectedObject
 	 * 
@@ -148,7 +148,7 @@ public class ObjectController {
 	 * @param ele
 	 * @param amount
 	 */
-	public void deleteElementInCategory(String cat, String obj, String ele, int amount) {
+	public void deleteElementInCategory(String cat, String obj, String ele) {
 		Category category = mpC.searchCat(cat);
 		HolonObject object = (HolonObject) mpC.searchCatObj(category, obj);
 		HolonElement element = mpC.searchEle(object, ele);