Question: Can you help me fix the errors? / * * * * * * * * * * * * * * * * *
Can you help me fix the errors?
METHODS TO BE COMPLETED
Check to see if two bags are equals.
@param aBag Another object to check this bag against.
@return True the two bags contain the same objects with the same frequencies.
public boolean equalsArrayBag aBag
boolean result true;
T t toArray;
T s aBag.toArray;
forint i ; i tlength; i
forint j ; j slength; j
ifsj null && sjequalsti
ti null;
sj null;
forint i ; i numberOfEntries; i
ifti null
result false;
forint i ; i aBag.numberOfEntries; i
ifsi null
result false;
COMPLETE THIS METHOD
return result;
end equals
Duplicate all the items in a bag.
@return True if the duplication is possible.
public boolean duplicateAll
checkIntegrity;
boolean success false;
ifnumberOfEntries bag.length
return success;
forint i ; i numberOfEntries; i
bagi numberOfEntries bagi;
success true;
COMPLETE THIS METHOD
return success;
end duplicateAll
Remove all duplicate items from a bag
public void removeDuplicates
checkIntegrity;
ifnumberOfEntries
return;
forint i ; i numberOfEntries ; i
forint j i ; j numberOfEntries; j
ifbagiequalsbagj
removebagj;
j;
return;
end removeDuplicates
end ArrayBag
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
