I'm given this test class from the teacher and I have an issue understanding how to implement my class to create itself in this order.
code:
t5: BOOLEAN
local
bag: MY_BAG[STRING]
bag3: like bag2
bag4: MY_BAG[STRING]
do
comment("t5:test add_all, remove all, remove")
bag := <<["nuts", 4], ["bolts", 11], ["hammers", 5]>> -- how to implement it to allow this?
bag3 := <<["nuts", 2], ["bolts", 6], ["hammers", 5]>>
-- add_all
bag3.add_all (bag1)
Result := bag3 |=| bag
check Result end
-- remove_all
bag3.remove_all (bag1)
Result := bag3 |=| bag2 and bag3.total = 13
check Result end
--remove
bag4 := <<["nuts", 2], ["bolts", 6]>>
bag3.remove ("hammers", 5)
Result := bag3 |=| bag4
end
setup -- inherit from ES_TEST redefine setup end
-- this runs before every test
do
bag1 := <<["nuts", 2], ["bolts", 5]>>
bag2 := <<["nuts", 2], ["bolts", 6], ["hammers", 5]>>
end
Currently when I compile with these kind of test cases it throws compiler errors saying creation is improper, incompatible
My constructors make an empty HASH_TABLE at the moment so my question is how do I make sure I can initialize my bag class in the way the code is testing it?