If you can add screen shots that would be a great help. What to submit: LotType1.java and LotType2.java (up to 10 points
Posted: Sun Jul 03, 2022 12:00 pm
If you can add screen shots that would be a greathelp.
What to submit: LotType1.java and LotType2.java (up to10 points may be deducted for submitting anything else, or notsubmitting these files, or naming them differently). Additionaldeductions (also up to 10 points) may be made for poor codestyle: lack of program headers, lack of methods headers, lackof in-code block-level commenting).
Set up: Download Lot.java and TestLots.java, andimport them into a blank NetBeans project (or if you're using adifferent IDE, import/open the files in whichever manner isappropriate for that IDE).
Requirements:
For this lab, you’ll be provided two files. Do not makeany changes in these (20 points for no changes in these two files;I will be using my own files to test, so changing yours wouldresult in this deduction, if it turns out that your lab only"works" with your versions of Lot.java andTestLots.java):
Lot.java: abstract class, parent of the two classesyou’ll have to implement
TestLots.java: driver file, run this file once you haveeverything implemented. The results you should get are specified inthat file’s header
Your assignment is to implement the two child classes ofthe abstract Lot class, and to make them Comparable (implement theComparable<Lot> interface). Your compareTo function resultsshould be based on the area of the Lot:
LotType1.java: extend Lot, implementComparable<Lot> interface. Lots of Type 1 are triangular, usethis information to implement the area calculation correctly (40points total; 20 points for correct abstract class extension, 20points for correct interface implementation).
LotType2.java: same, but lots of Type 2 are rectangular-- use the correct formula for area (40 points total; 20 points forcorrect abstract class extension, 20 points for correct interfaceimplementation).
Once you’ve successfully implemented both of theseclasses, you should be able to run TestLots and get correct (andcorrectly sorted) results. Make sure all four files are included inthe same NetBeans project.
Note: there is no need to submit either Lot.java orTestLots.java -- I will use my own for testing (they'll be exactlythe same as the ones you downloaded, this is just meant to test for"no changes" in those files). Please submit only LotType1.java andLotType2.java.
Lot:
/* abstract class, parent of LotType1 and LotType2*/
public abstract class Lot {
public abstract doublecalculateArea();
public abstract StringgetID();
@Override // Implement thetoString method in GeometricObject
public String toString(){
return "Lot ID "+getID() +" has area: "+ calculateArea();
}
}
LestLots:
/* driver to test code -- use with Lot.java,LotType1.java, LotType2.java */
/* implement LotType1 and LotType2 prior to testing*/
/* once everything is correctly implemented, the outputof this driver
will be:
Lot ID L3 has area: 13500.0
Lot ID L2 has area: 27000.0
Lot ID L1 has area: 35000.0
Lot ID L4 has area: 70000.0
*/
public class TestLots {
public static void main(Stringargs[]){
// an array of lots -- some oftype1, some of type2
Lot[] lots = {newLotType1("L1",350, 200),
newLotType2("L2",100,270),
newLotType1("L3",100, 270),
newLotType2("L4",350,200)
};
// sort the lots of mixed typesby area (note, you'll have to implement
// Comparable interfacecorrectly in LotType1 and LotType2 for this to work:
java.util.Arrays.sort(lots);
// print out sortedresults
for (Lot lot: lots){
System.out.print(lot+ " ");
System.out.println();
}
}
}
What to submit: LotType1.java and LotType2.java (up to10 points may be deducted for submitting anything else, or notsubmitting these files, or naming them differently). Additionaldeductions (also up to 10 points) may be made for poor codestyle: lack of program headers, lack of methods headers, lackof in-code block-level commenting).
Set up: Download Lot.java and TestLots.java, andimport them into a blank NetBeans project (or if you're using adifferent IDE, import/open the files in whichever manner isappropriate for that IDE).
Requirements:
For this lab, you’ll be provided two files. Do not makeany changes in these (20 points for no changes in these two files;I will be using my own files to test, so changing yours wouldresult in this deduction, if it turns out that your lab only"works" with your versions of Lot.java andTestLots.java):
Lot.java: abstract class, parent of the two classesyou’ll have to implement
TestLots.java: driver file, run this file once you haveeverything implemented. The results you should get are specified inthat file’s header
Your assignment is to implement the two child classes ofthe abstract Lot class, and to make them Comparable (implement theComparable<Lot> interface). Your compareTo function resultsshould be based on the area of the Lot:
LotType1.java: extend Lot, implementComparable<Lot> interface. Lots of Type 1 are triangular, usethis information to implement the area calculation correctly (40points total; 20 points for correct abstract class extension, 20points for correct interface implementation).
LotType2.java: same, but lots of Type 2 are rectangular-- use the correct formula for area (40 points total; 20 points forcorrect abstract class extension, 20 points for correct interfaceimplementation).
Once you’ve successfully implemented both of theseclasses, you should be able to run TestLots and get correct (andcorrectly sorted) results. Make sure all four files are included inthe same NetBeans project.
Note: there is no need to submit either Lot.java orTestLots.java -- I will use my own for testing (they'll be exactlythe same as the ones you downloaded, this is just meant to test for"no changes" in those files). Please submit only LotType1.java andLotType2.java.
Lot:
/* abstract class, parent of LotType1 and LotType2*/
public abstract class Lot {
public abstract doublecalculateArea();
public abstract StringgetID();
@Override // Implement thetoString method in GeometricObject
public String toString(){
return "Lot ID "+getID() +" has area: "+ calculateArea();
}
}
LestLots:
/* driver to test code -- use with Lot.java,LotType1.java, LotType2.java */
/* implement LotType1 and LotType2 prior to testing*/
/* once everything is correctly implemented, the outputof this driver
will be:
Lot ID L3 has area: 13500.0
Lot ID L2 has area: 27000.0
Lot ID L1 has area: 35000.0
Lot ID L4 has area: 70000.0
*/
public class TestLots {
public static void main(Stringargs[]){
// an array of lots -- some oftype1, some of type2
Lot[] lots = {newLotType1("L1",350, 200),
newLotType2("L2",100,270),
newLotType1("L3",100, 270),
newLotType2("L4",350,200)
};
// sort the lots of mixed typesby area (note, you'll have to implement
// Comparable interfacecorrectly in LotType1 and LotType2 for this to work:
java.util.Arrays.sort(lots);
// print out sortedresults
for (Lot lot: lots){
System.out.print(lot+ " ");
System.out.println();
}
}
}