Question: Please answer correctly, show correct code and output of compiled code. C: Programming Modify the Box class so that it is a concrete class. The
Please answer correctly, show correct code and output of compiled code.
C: Programming Modify the Box class so that it is a concrete class. The natural ordering of boxes should be as follows (let b1 and b2 be two box instances): b1 is less then b2 whenever b1s rst attribute is shorter (in length) than b2s rst attribute. b1 is greater then b2 whenever b1s rst attribute is longer than b2s rst attribute. When the rst attributes have the same length, b1 is smaller than b2 when its second attribute comes before b2s second attribute alphabetically (and greater than it comes after alphabetically). b1 and b2 are the same when their rst attributes are the same length and their second attributes are the same. 1 public class Box implements Comparable{
2 protected String first;
3 protected String second; 4 5 public Box(String f, String s){ 6 first = f; 7 second = s; 8 } 9 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
