troubles with Vector2D
I wonder why does this not compile?
it says, Vector2D[] cannot be resolved or is not a type. ;(
thanks!
// Rect.java
import java.io.*;
public class Rect
{
public static Vector2D getPoint(int i)
throws IOException
{String s;
float x = 0.0f, y = 0.0f;
BufferedReader in = new BufferedReader
(new InputStreamReader(System.in));
System.out.print("x"+i+"= "); System.out.flush();
s = in.readLine();
x = Float.parseFloat(s);
System.out.print("y"+i+"= "); System.out.flush();
s = in.readLine();// read keyboard input as string
y = Float.parseFloat(s);
return new Vector2D(x,y);
}
public static void main(String[] args)
throws IOException
{int i;
System.out.println("Enter vertices 0, 1, 2, 3");
Vector2D[] point = new Vector2D[4];
for ( i = 0; i < 4; i++)
point = getPoint(i);
for ( i = 0; i < 4; i++)
System.out.print(point + " ");
Vector2D v;
Vector2D u = point[1].minus(point[0]);
for ( i = 0; i < 3; i++)
{ v = point[(i+2)%4].minus(point[i+1]);
if ( ! u.isPerpendicular(v) )
{System.out.println("No, not a rectangle.");
return;
}
u = v;
}
System.out.println("Yes, a rectangle.");
}
}

