Not sure wheter to post it here or not, but I've got a question.
I'm Trying to make the following:
A Class called Point with the methods:
SetPoint() //Sets pointx to 0 and pointy to 0
SetPointNumber(int x, int y) //Set pointx to x and pointy to y
Print() //Print pointx & pointy
A Class called Shape with the methods:
ShapeCreate() - This must create 3 points (an array) and set the point x & y to 0.
I've got the following:
class Point { int x, y; void Point() { x = 0; y = 0; } void Set(int x, int y) { this.x = x; this.y = y; } void Print() { System.out.println("x = " + x + "\nY = " + y); } } class Shape { void Shape() { Point Points[] = new Point[3]; Point[1].Print(); Point[2].Print(); Point[3].Print(); } } public class Practicum4VeelHoek { public static void main(String[] args) { Shape shape = new Shape(); } }
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at practicum.pkg4.veelhoek.Veelhoek.Init(Practicum4Ve elHoek.java:29)
at practicum.pkg4.veelhoek.Practicum4VeelHoek.main(Pr acticum4VeelHoek.java:50)
Java Result: 1
Does anybody know what I'm doing wrong