0

I made an array of objects (point) that each have a pointID. However, when I enter input for choice1, the while statement cannot find the input from the objects. For example, when I input "point1", I still get a message of "Please enter valid pointID"

point[] points= new point[8];

    for (int i=0; i<8; i++)
    {
        points[i]=new point();
        String num=Integer.toString(i+1);
        points[i].pointID="point"+ num;
        points[i].x=randInt();
        points[i].y=randInt();
        points[i].z=randInt();
    }

    String choice1= JOptionPane.showInputDialog("Please enter pointID from point1 to point8:");

    while (points[0].pointID!=choice1 && points[1].pointID!=choice1 && points[2].pointID!=choice1 && points[3].pointID!=choice1 && points[4].pointID!=choice1 
        && points[5].pointID!=choice1 && points[6].pointID!=choice1 && points[7].pointID!=choice1)
    {
        JOptionPane.showMessageDialog(null,"Please enter valid pointID");
        choice1= JOptionPane.showInputDialog("Please enter pointID from point1 to point8:");
Andrew
  • 91
  • 1
  • 1
  • 2

0 Answers0