Tuesday, 27 August 2013

why do I get expected?

why do I get expected?

The following code
import java.util.ArrayList;
import java.awt.Point;
public class Polygon{
// TODO: provide the required constructor, instance variable, and methods
//instanc variables
ArrayList<Point> points;
/**
* constructs polygon without points
*/
public Polygon() {
points = new ArrayList<Point>();
}
/*
* adds a point to points
*/
public void addPoint(Point){
points.add(Point);
}
public void draw(){
for(int i = 0; i < points.size(); i++){
if(i == 0){
points.get(0).draw()
}else{
points.get(i).draw()
Line line = new Line(points.get(i-1).getX(),
points.get(i-1).getY(), points.get(i).getX(),
points.get(i).getY());
line.draw();
}
}
if(points.size() >= 2){
Line line = new Line(points.get(-1).getX(),
points.get(-1).getY(), points.get(-2).getX(),
points.get(-2).getY());
line.draw();
}
}
}
gives the error message expected for public void addPoint(Point){
I just cannot figure out why? Those identifiers are normally needed to
tell an ArrayList which objects it is going to hold, right?
Thanks a lot!

No comments:

Post a Comment