首页 > > 详细

COMP 1006辅导、辅导Python、c++程序

Assignment #3 Due Friday, November 19th at 11:59 pm
COMP 1006/1406 – Fall 2021
There are 20 possible marks.
1 Implementing Comparable [10 marks] r>10 Marks : All marks for this problem are correctness marks.
Consider the following abstract class.
public abstract class Box implements Comparable{
String label;
String location;
int size;
public String getLabel(){ return this.label;}
public int getSize(){ return this.size;}
public String getLocation(){ return this.location;}
}
You will complete the provided SpecificBox class which extends the Box class. The SpecificBox
class must be a concrete class. The SpecificBox class must be completed so that a total ordering
is imposed on SpecificBox objects as follows: Let A and B be SpecificBox objects, then
(a) A < B whenever A’s location is alphabetically “less than” B’s location
(b) A < B whenever A and B have the same location and length(A’s label) < length(B’s label)
(c) A < B whenever A and B have the same location, the lengths of their labels are the same,
and A’s size is larger than B’s size.
(d) A = B whenever A and B have the same location, their label lengths are the same and their
sizes are the same
(e) otherwise B < A
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.
When you implement your SpecificBox class, the compareTo() method should only return
one of seven different numbers. If the locations of the boxes are different it should return ±1, if
the locations are the same but the lengths of the labels are different it should return ±2, if the
locations and label lengths are the same but the size is different it should return ±3. If they are
the same box (by state) then it should return 0.
Submit your SpecificBox.java file to Brightspace.
Do not change the provided Box class.
Do not change the constructor signature of the SpecificBox class.
COMP 1006/1406 - Fall 2021 1
Assignment #3 Due Friday, November 19th at 11:59 pm
2 Testing Your SpecificBox Class [10 marks]
10 Marks : Each “different” test case is worth 1.5 marks. 1 additonal mark overall.
In a plain-text file called testcases.txt, write SIX test cases to test the compareTo() method
in your SpecificBox class. Each test case should test something different. Each test case will
consist of FIVE (or more) lines in the testcases.txt file as follows:
testN
location1,label1,size1
location2,label2,size2
expected
#comment
The first line is just a label for the given test case (you will label then “test1”, “test2”, ...,
“test6” without the quotes). The next two lines contain the needed information to create two
SpecificBox objects, b1 and b2, respectively, the fourth line is the expected output when calling
b1.compareTo(b2), and the fifth line is a comment explaining what you are testing. The fifth line
must begin with a # sign. If your comments are long then you break it up over multiple lines for
readability. If a comment has more than 60 characters (including spaces) it should be broken up
as follows:
testN
location1,label1,size1
location2,label2,size2
expected
#comments up to about 60 characters
#more comments here that didn’t fit in the line above
#and even more here...
For the expected value, it should be a number from the set {0,±1,±2,±3}. The specific value
should correspond the description above (Problem 1).
Here is an example of one test case.
test1
Ottawa,Cat,12
Ottawa,Cat,12
0
#Testing for specific boxes that are the same.
#You will not receive a mark for testing the same boxes
Take care that you do NOT add any extra whitespace to your file. This includes spaces, empty
lines, etc. In the first FOUR lines of each test case, there should be no spaces at all. You should have
spaces in your comments for readability. Be sure that each test case tests something “different”.
You are NOT allowed to use the example provided above. This means that any test case with an
expected output of 0 is not allowed. Each test case is worth 1.5 marks (1 for the valid “different”
test case and 0.5 for comments). The final mark is for a good choice of test cases overall.
Submit your testcases.txt file to Brightspace.
COMP 1006/1406 - Fall 2021 2
Assignment #3 Due Friday, November 19th at 11:59 pm
Brightspace warning
Brightspace will only keep your most recent submission. This means that you have to submit
all files each time. If you submit only the testcases.txt file the last time, then any
previous submission of SpecificBox.java will be automatically deleted. Be sure to check
that all files you want to submit are submitted!
COMP 1006/1406 - Fall 2021 3

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!