Trouble creating object that includes array
Hello. I'm new in the world of Java and in this forum, so please excuse me if I'm posting in the wrong section or explaining my problem in a false manner and please dont refrain from noting it in your reply.
Well, here is the thing. I'm trying to code a small spaceship shooter game and this is my first time dealing with objects.
I have this class at my disposal
Code:
public Polygon(Point[] inShape, Point inPosition, double inRotation)
The Polygon class gets a series of point coordinates (inShape) that form a shape, the coordinates of this shape's current position (inPosition) and inRotation has nothing to do with my problem :P
The way Polygon works is, also, irrelevant (I think.)
I use the class Point as a means of storing coordinates. Here is the code:
Code:
class Point {
double x;
double y;
public Point(double inX, double inY) {
x = inX;
y = inY;
}
public Point clone() {
return new Point(x, y);
}
}
And here is where the trouble is. I also have a class named Ship which represents the spaceship and is a subclass of Polygon.
Code:
public class Ship extends Polygon {
In there i'm trying to define the shape of the spaceship by creating Point type objects, that I will then pass over to Polygon to process the shape and it's position in space. I cant create a Point[] Object successfully, i guess because am using the wrong syntax when trying to fill an array with coordinate pairs.
These are some of my numerus failed experimental attempts to do it. I got frustrated so most of them are just random typing. They might not make any sense at all...
Code:
Point[] Alpha = {(0,0), (2,1), (4,0), (2,4)};
Point[] Alpha = new Point[] {(0,0), (2,1), (4,0), (2,4)};
Point[] Alpha = new Point[4] {(0,0), (2,1), (4,0), (2,4)};
Point[] Alpha = new Point[] [(0,0), (2,1), (4,0), (2,4)];
Point[] Alpha = new Point[] (0,0), (2,1), (4,0), (2,4);
Point[] Alpha = new Point[] {(0.0), (2.1), (4.0), (2.4)};
The basic error that occurs is : Syntax error on token ",", invalid AssignmentOperator. and it refers to the commas inside the coordinates' brackets. Here I should note that I work on Eclipse.
Can anyone point out to me which is the ridiculus syntax mistake that tortures me? Thank you very much :D