Please perform test cases according to the intructions provided. Box code is given below. Question is in JAVA.  Thanks! -------------------

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 1DE
icon
Related questions
Question

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;
   }

}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Block Comments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT