I'm having some problems with chapter 9, if anyone could help...I'm getting a classcastexception with the tester for the unitGroup class. Here's some code...
// GET ALL UNITS WITHIN A GROUP
public List getUnits()
{
List unitList = new LinkedList();
for (Iterator i = units.entrySet().iterator(); i.hasNext(); ) { //
Unit unit = (Unit)i.next();
unitList.add(unit);
}
return unitList;
}
// MY TEST METHOD...
public void testCreateUnitGroup (List unitList, List expectedOutput)
{
System.out.print("\nTest # 1: CREATE A NEW UNITGROUP FROM A LIST...");
UnitGroup testGroup = new UnitGroup(unitList);
List Output = testGroup.getUnits();
if (expectedOutput.equals(Output))
{
System.out.println("PASSED");
}
else
{
System.out.println("FAILED");
System.out.println(""+Output);
}
}
public static void main(String[] args)
{
// TEST # 1: Create a new Group
UnitGroupTester tester = new UnitGroupTester();
Unit unit1, unit2, unit3;
List unitList = new LinkedList();
unitList.add(unit1 = new Unit(10));
unitList.add(unit2 = new Unit(20));
unitList.add(unit3 = new Unit(30));
tester.testCreateUnitGroup(unitList, unitList);
}
Again, any help or orientation with this problem would be greatly appreciated











