COMP1406/1006 Tutorial 0 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] 10 Marks : All marks for this...

1 answer below »
Complete the text files as well as the specific box java file. and send it to me using the box.java and sampleboxes.java files


COMP1406/1006 Tutorial 0 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] 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 implementing comparable [10 marks] testing your specificbox class [10 marks] 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="" implementing="" comparable="" [10="" marks]="" testing="" your="" specificbox="" class="" [10="">
Answered 1 days AfterNov 16, 2021

Answer To: COMP1406/1006 Tutorial 0 Assignment #3 Due Friday, November 19th at 11:59 pm COMP 1006/1406 – Fall...

Kondalarao answered on Nov 18 2021
130 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here