I am trying to add objects to my arraylist with which I can then implement a few methods referencing an element of the object. I have two classes Balloons and MyPark (both implement other interfaces but that's irrelavant). In the balloon class there is:
public class Balloons implements Balloon {
private int area;
private int position;
public void Balloon(int area, int position) {
this.area = area;
this.position = position;
}
@Override
public int getArea() {
return area;
}
}
And in the MyPark I have created my Arraylist of balloons:
import java.util.*;
public class MyPark implements Park {
public Balloons balloon = new Balloons;
public ArrayList <Balloon> a = new ArrayList <Balloon>();
public int index;
@Override
public void addBalloon (int barea){
a.add(new Balloons (barea, index));
}
}
But obviously this isn't the way to do it. Any suggestions? I also want to be able to eventually sort the list by area......
public class Balloons implements Balloon { public void Balloon(...: are you engaged in an obfuscation contest or what? Don't use the same name for everything. And respect the Java naming conventions.