Please perform test cases according to the intructions provided. Box code is given below. Question is in JAVA. Thanks! -------------------
Please perform test cases according to the intructions provided. Box code is given below. Question is in JAVA. Thanks!
-------------------------------------------------------------------------------------------
Recall the SpecificBox. When testing your class, what is the
minimum number of test cases that should be used? Provide these (minimum number of) test
cases in a text file called tests.txt. Each test case in the file should have the following format
(for example, if this is your 3rd test)
// Test 3
// TESTING - testing XYZ
box1 = new SpecificBox(label1, location1, size1);
box2 = new SpecificBox(label2, location2, size2);
expected = exp; // an integer
actual = box1.comppareTo(box2);
Here, label1, label2, location1, location2, size1, size2, and exp are values you supply. The
TESTING comment should provide a brief description of what is being tested. Note that pasting
any of your test cases in to the following code should work:
SpecificBox box1, box2;
int expected, actual;
//
// your test copied here
//
System.out.println("test passed : " + (expected == actual);
At the end of your tests.txt file, briefly explain what you need these number of tests
-----------------------------------------------------------------------------------
BOX CODE:
SpecificBox.java
public class SpecificBox extends Box {
public SpecificBox(String label, String location, int size) {
this.label = label;
this.location = location;
this.size = size;
}
/**
* Another way of specifying the ordering would be to consider a sorted list of
* SpecificBox objects. They would first be sorted by location (alphabetically),
* then for ties (that is, having the same location) sorted by length of labels,
* and finally for ties in both sorted by size from largest to smallest.
*/
@Override
public int compareTo(Box o) {
if (location.compareTo(o.location) > 0) {
return 1;
} else if (location.compareTo(o.location) < 0) {
return -1;
} else {
if (label.length() > o.label.length()) {
return 2;
} else if (label.length() < o.label.length()) {
return -2;
} else {
if (size < o.size) {
return 3;
} else if (size > o.size) {
return -3;
}
}
}
return 0;
}
}
Step by step
Solved in 2 steps with 1 images