0

Java

Define a class named ShapeList ShapeList must extend ArrayList<Shape> ShapeList must have a method with signature: ShapeList largestShapes() The largestShapes method must return a ShapeList that contains all Shapes with the largest area ShapeList must have a method with signature: boolean hasDistinctAreas() The hasDistinctAreas method returns true means that: for all Shape A and Shape B in the ShapeList, if A and B have the same area, then A.equals(B) is true in other words, it returns true if distinct shapes have distinct areas My code is below. What wrong with this? Can someone help me import java.util.ArrayList; public class ShapeList extends ArrayList<Shape> { public void largestShapes(){ int resultList[] = new int[this.size()]; int largestArea =0; for (int i=0; i< this.size(); i++){ if (computeArea(this[i])) > largestArea){ largestArea = computeArea(this[i]); } return resultList[]; } } public boolean hasDistinctAreas(){

9th Sep 2018, 10:45 PM
Tuyen Pham
Tuyen Pham - avatar
2 RĂ©ponses
+ 1
This sure isn't a question. Please post it on your personal feed or as a Java lesson
9th Sep 2018, 11:11 PM
Dlite
Dlite - avatar
+ 1
Why did you even import ArrayList if it isn't in your code? Plus, you could use ArrayList in line 1 of largestShapes()
9th Sep 2018, 11:13 PM
👑 Prometheus 🇾🇬
👑 Prometheus 🇾🇬 - avatar