Question
$3.00 Java Help with Copy Constructor and Equals Method.
- From Computer-Science: Object-Oriented-Programming
- Closed, but you can still post tutorials
- Due on May. 31, 2009
- Asked on May 31, 2009 at 2:45:03PM
Q:
This relates to the SimpleSet code that we discussed in class. Please add: 1) a copy constructor and 2) and equals method. The signatures would be:
public SimpleSet(SimpleSet sourceSet) { ... }
public boolean equals(SimpleSet otherSet) { ... }
The copy constructor should create an exact duplicate of the sourceSet argument. The equals() method should return true only if all of the real elements (not the -1 placeholders) appears in both sets - the order of the values doesn't matter.
Please provide a sample test in the SimpleSetTest.java file provided in the attachment. Also the above code needs to go at the end of SimpleSet.java file provided in the attachment.
thank you
public SimpleSet(SimpleSet sourceSet) { ... }
public boolean equals(SimpleSet otherSet) { ... }
The copy constructor should create an exact duplicate of the sourceSet argument. The equals() method should return true only if all of the real elements (not the -1 placeholders) appears in both sets - the order of the values doesn't matter.
Please provide a sample test in the SimpleSetTest.java file provided in the attachment. Also the above code needs to go at the end of SimpleSet.java file provided in the attachment.
thank you
Added the copy constructor and equal method
- This tutorial hasn't been purchased yet.
- Posted on May 31, 2009 at 3:13:01PM
