I'm doing the following problem:
Create a record called Point that contains 2 fields: X (Real) and Y (Real), which represent the coordinates of a point. Create a Register called Triangle that contains 3 fields of type Point. I develop the method "void typeTriangulo (Triangle T)" that given a This triangle prints the type of triangle.
I have done this:
class punto {
static int x;
static int y;
}
class triangulo {
static punto a;
static punto b;
static punto c;
}
public class Ejercicio {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
punto c1 = null;
System.out.println("Ingrese la variable x");
c1.x = sc.nextInt();
sc.nextLine();
System.out.println("Ingrese la variable y");
c1.y = sc.nextInt();
sc.nextLine();
punto c2 = null;
System.out.println("Ingrese la variable x");
c2.x = sc.nextInt();
sc.nextLine();
System.out.println("Ingrese la variable y");
c2.y = sc.nextInt();
sc.nextLine();
punto c3 = null;
System.out.println("Ingrese la variable x");
c3.x = sc.nextInt();
sc.nextLine();
System.out.println("Ingrese la variable y");
c3.y = sc.nextInt();
sc.nextLine();
triangulo PrimerPuntoTriangulo = null;
PrimerPuntoTriangulo.a.x = (c1.x);
PrimerPuntoTriangulo.b.y = (c2.y);
triangulo SegundoPuntoTriangulo = null;
SegundoPuntoTriangulo.a.x = (c2.x);
SegundoPuntoTriangulo.b.y = (c2.y);
triangulo TercerPuntoTriangulo = null;
TercerPuntoTriangulo.a.x = (c3.x);
TercerPuntoTriangulo.b.y = (c3.y);
if (PrimerPuntoTriangulo.equals(SegundoPuntoTriangulo) && SegundoPuntoTriangulo.equals(TercerPuntoTriangulo)) {
System.out.println("El triangulo es Equilatero");
} else if (PrimerPuntoTriangulo.equals(SegundoPuntoTriangulo) || PrimerPuntoTriangulo.equals(TercerPuntoTriangulo) || SegundoPuntoTriangulo.equals(TercerPuntoTriangulo)) {
System.out.println("El triangulo es Isoceles");
} else {
System.out.println("El triangulo es Escaleno");
}
}
}
In this line:
if (PrimerPuntoTriangulo.equals(SegundoPuntoTriangulo) && SegundoPuntoTriangulo.equals(TercerPuntoTriangulo)) {
Netbeans throws me the following error:
java.lang.NullPointerException
Could someone help me with this?