code correction please, i get an error (SeatingChart Null Pointer)

import java.util.Arrays.*;

int size=100;
Student[][] stud;

void setup()
{
  size(500, 500);
  int num=0;
  for (int i=0; i<20; i++) {
    for (int j=0; j<20; j++) {
      num++;
      int rand=(int)(random(1));
      if (rand==1)
        stud[i][j]=new Student("stud"+num, (int)(random(6)));
      else
        stud[i][j]=new Student("name only");
    }
  }
  drawChart(stud);

  // Your code goes here to create your Student[] array, 
  //     Student[][] twoDarray and SeatingChart object.
  // Your code to test the Student and SeatingChart class also goes here.
}

/** the drawChart method should display the seating chart data
 * with students in the correct rows and columns
 */
void drawChart(Student[][] newSeatingChart)
{
  for (int i=0; i<width/size; i++) {
    for (int j=0; j<height/size; j++) {
      stroke(0);
      fill(255);
      rect(i*size, j*size, size, size);
      text("stud", i*size, j*size);
    }
  }
}



public class Student 
{ 
  private String name;
  private int absenceCount;

  public Student ( String nm )
  {  
    name = nm;
  }

  public Student ( String nm, int count )
  {  
    name = nm; 
    absenceCount = count;
  }

  public void setAbsenceCount( int ac )
  {   
    absenceCount = ac;
  }

  /** Returns the name of this Student. */
  public String getName()  
  {  
    return name;
  }

  /** Returns the number of times this Student has missed class. */
  public int getAbsenceCount() 
  {  
    return absenceCount;
  } 

  public String toString()
  {  
    return name + " " + absenceCount + " ";
  }
}

public class SeatingChart
{
  /** seats[r][c] represents the Student in row r and column c in the classroom. */
  private Student[][] seats; 

  /** Creates a seating chart with the given number of rows and columns from the students in 
   * studentList. Empty seats in the seating chart are represented by null.
   * @ param rows the number of rows of seats in the classroom
   * @ param cols the number of columns of seats in the classroom
   * Precondition:  rows > 0; cols > 0;
   * rows * cols >= studentList.size() 
   * Postcondition:
   * - Students appear in the seating chart in the same order as they appear
   * in studentList, starting at seats[0][0]. 
   * - seats is filled column by column from studentList, followed by any
   * empty seats (represented by null).
   * - studentList is unchanged.
   */
  public SeatingChart(Student[] studentArray, int rows, int cols)
  {
    // your code here to initialize the seats array with the values passed in
    seats=new Student[rows][cols];
  }

  public Student[][] getSeats() { 
    return seats;
  }

  /** Removes students who have more than a given number of absences from the
   * seating chart, replacing those entries in the seating chart with null
   * and returns the number of students removed.
   * @ param allowedAbsences an integer >= 0
   * @ return number of students removed from seats
   * Postcondition:
   * - All students with allowedAbsences or fewer are in their original positions in seat
   * - No student in seats has more than allowedAbsences absences.
   * - Entries without students contain null.
   */
  public int removeAbsentStudents(int allowedAbsences)
  {
    int removed=0;
    // your code goes here to removeAbsentStudents from seats
    for (int i=0; i<seats[0].length; i++) {
      for (int j=0; j<seats.length; j++) {
        if (seats[i][j].absenceCount>=allowedAbsences)
          removed++;
      }
    }
    return removed;
  }

  /** Rearrange students in the seating chart in alphabetical order
   * with a new set of rows and columns
   * and returns the new seating chart. The original seating chart
   * is not affected.
   * @ param rows - may be different from the original number of rows
   * @ param col - may be different from the original number of columns
   * Postcondition:
   * - All students with be in the new seating chart
   * - The original seating chart is the same
   */
  public Student[][] rearrangedStudents(int rows, int cols)
  {
    Student[][] updatedList=new Student[rows][cols];
    for (int i=0; i<seats[0].length; i++) {
      for (int j=0; j<seats.length; j++) {
        if (seats[i][j].name.charAt(0)<seats[i+1][j+1].name.charAt(0)) {
          seats[i][j]=seats[i+1][j+1];
          seats[i+1][j+1]=seats[i][j];
        }
      }
    }
    return updatedList;
  }

  public String toString()
  {  
    // your code here
    return " ";
  }
}

here is the error

Exception in thread "Animation Thread" java.lang.NullPointerException

at seatingChartStudentVersion.setup(seatingChartStudentVersion.java:33)

at processing.core.PApplet.handleDraw(PApplet.java:2377)

at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1527)

at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
Tagged:

Answers

  • edited April 2016

    Please do not post code w/ /* lest it gets all GREEN! :-& Replace all of them w/ /** instead. *-:)

    // forum.Processing.org/two/discussion/15830/
    // code-correction-please-i-get-an-error
    
    // 2016-Apr-03
    
    static final int ROOMS = 20, ALUMS = 20;
    final Student[][] school = new Student[ROOMS][ALUMS];
    
    void setup() {
      for (Student[] room : school)  for (int alum = 0; alum < ALUMS; ++alum)
        room[alum] = new Student("lolnyancats");
    }
    
    static class Student {
      final String name;
    
      Student (String nm) {
        name = nm;
      }
    }
    
  • @gotoloop thanks, I cant believe I forgot that XD

  • edited April 2016

    @gotoloop can you explain why

    stud[0][1]=new Student("Mark");
    
      stud[1][0]=new Student("Joe");
    
      stud[0][3]=new Student("Jacob");
    
      stud[0][4]=new Student("Hailey");
    
      drawChart(stud);
    

    returns an error

    Exception in thread "Animation Thread" java.lang.NullPointerException

    at seatingChartStudentVersion$Student.access$1(seatingChartStudentVersion.java:70)
    
    at seatingChartStudentVersion.drawChart(seatingChartStudentVersion.java:61)
    
    at seatingChartStudentVersion.setup(seatingChartStudentVersion.java:42)
    
    at processing.core.PApplet.handleDraw(PApplet.java:2377)
    
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1527)
    
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316) 
    

    it is in the setup method

    figured out, the array was not full so returned that error

  • edited April 2016

    Each sub-array (2nd inner dimension) needs to be created.
    Something like this new Student[ROOMS][ALUMS]; instantiates both dimensions.
    However, new Student[ROOMS][]; only creates the 1st outer dimension.

  • @gotoloop I have a new error of a nullpointerexception

    import java.util.Arrays.*;
    int size=100;
    //Student[] stud;
    //SeatingChart[][] seats;
    ArrayList<Student> roster;
    void setup()
    {
      //stud=new Student[50];
      //stud[0]=new Student ("Jin");
      //stud[1]=new Student ( "Alta" );
      //stud[2]=new Student ( "Rosan");
      //stud[3]=new Student ( "Helena");
      //stud[4]=new Student ( "Jeanice");
      //stud[5]=new Student ( "Noah");
      //stud[6]=new Student ( "Collen" );
      //stud[7]=new Student ("Jerold"); 
      //stud[8]=new Student ( "Petra");
      //stud[9]=new Student ( "Araceli" );
      //stud[10]=new Student ( "Eunic");
      //stud[11]=new Student ( "Tosh");
      //stud[12]=new Student ("Denny");
      //stud[13]=new Student ( "Jesus");
      //stud[14]=new Student ( "Peg");
      //stud[15]=new Student ( "Fawn");
      //stud[16]=new Student ("Raylene");
      //stud[17]=new Student (  "Reyes");
      //stud[18]=new Student ( "Ayako");
      //stud[19]=new Student ( "Clifford");
      //stud[20]=new Student ( "Cara"); 
      //stud[21]=new Student (  "Elsy");
      //stud[22]=new Student ( "Maple");   
      //stud[23]=new Student ( "Kemberly");
      //stud[24]=new Student ( "Stephen"); 
      //stud[25]=new Student ( "Laurette");
      //stud[26]=new Student ("Shantelle"); 
      //stud[27]=new Student (  "Tommye");
      //stud[28]=new Student ( "Marylin");
      //stud[29]=new Student ( "Tess");
      //stud[30]=new Student (  "Letisha");
      //stud[31]=new Student ( "Georgetta"); 
      //stud[32]=new Student ( "Lorri"); 
      //stud[33]=new Student (  "Tabetha");
      //stud[34]=new Student ( "Camila");
      //stud[35]=new Student ( "Leif");
      //stud[36]=new Student ( "Billye");
      //stud[37]=new Student ( "Amparo");
      //stud[38]=new Student ( "Mariela");
      //stud[39]=new Student ( "Maritza"); 
      //stud[40]=new Student ( "Eliseo"); 
      //stud[41]=new Student ( "Torrie"); 
      //stud[42]=new Student (  "Pia"); 
      //stud[43]=new Student ( "Karisa" );
      //stud[44]=new Student ( "Bethel"); 
      //stud[45]=new Student ( "Minna"); 
      //stud[46]=new Student ( "Ling"); 
      //stud[47]=new Student ( "Randi"); 
      //stud[48]=new Student ( "Terra"); 
      //stud[49]=new Student ( "Nicholle");
      size(500, 500);
    
      roster = new ArrayList<Student>();
      roster.add(new Student("Jin", 3));
      roster.add(new Student("Alta", 11));
      roster.add(new Student("Paul", 9));
      roster.add(new Student("Piar", 1));
      roster.add(new Student("Terra", 1));
      roster.add(new Student("Ayako", 9));
      roster.add(new Student("Glen", 2));
      roster.add(new Student("Fran", 1));
      roster.add(new Student("David", 4));
      roster.add(new Student("Danny", 3));
      SeatingChart apcs = new SeatingChart(roster, 3, 4);
      apcs.removeAbsentStudents(1,roster);
      apcs.drawChart(roster);
    
      //int num=0;
      //for (int i=0; i<20; i++) {
      //  for (int j=0; j<20; j++) {
      //    num++;
      //    int rand=(int)(random(2));
      //    println(rand);
      //    if (rand==1)
      //      stud[i][j]=new Student("stud"+num, (int)(random(6)));
      //    else
      //      stud[i][j]=new Student("name only");
      //  }
      //}
      //stud[0][0]=new Student("Student");
      //stud[0][1]=new Student("Marks", 2);
      //stud[0][2]=new Student("Joe");
      //stud[0][3]=new Student("Jacobs");
      //stud[0][4]=new Student("Hailey");
      //stud[0][5]=new Student("Hailey");
    
      //stud[1][0]=new Student("Joe");
      //stud[1][1]=new Student("Jacob");
      //stud[1][2]=new Student("Hailey");
      //stud[1][3]=new Student("Mark");
      //stud[1][4]=new Student("Joe");
      //stud[1][5]=new Student("Joe");
    
      //stud[2][0]=new Student("Joe");
      //stud[2][1]=new Student("Jacob");
      //stud[2][2]=new Student("Hailey");
      //stud[2][3]=new Student("Mark");
      //stud[2][4]=new Student("Joe");
      //stud[2][5]=new Student("Joe");
    
      //stud[3][0]=new Student("Joe");
      //stud[3][1]=new Student("Jacob");
      //stud[3][2]=new Student("Hailey");
      //stud[3][3]=new Student("Mark");
      //stud[3][4]=new Student("Joe");
      //stud[3][5]=new Student("Joe");
    
      //stud[4][0]=new Student("Joe");
      //stud[4][1]=new Student("Jacob");
      //stud[4][2]=new Student("Hailey");
      //stud[4][3]=new Student("Mark");
      //stud[4][4]=new Student("Joe");
      //stud[4][5]=new Student("Joe");
    
      //stud[5][0]=new Student("Joe");
      //stud[5][1]=new Student("Jacob");
      //stud[5][2]=new Student("Hailey");
      //stud[5][3]=new Student("Mark");
      //stud[5][4]=new Student("Joe");
      //stud[5][5]=new Student("Joe");
    
      //drawChart(seats);
    
      // Your code goes here to create your Student[] array, 
      //     Student[][] twoDarray and SeatingChart object.
      // Your code to test the Student and SeatingChart class also goes here.
    }
    
    /** the drawChart method should display the seating chart data
     * with students in the correct rows and columns
     **/
    
    
    
    
    public class Student 
    { 
      private String name;
      private int absenceCount;
    
      public Student ( String nm )
      {  
        name = nm;
      }
    
      public Student ( String nm, int count )
      {  
        name = nm; 
        absenceCount = count;
      }
    
      public void setAbsenceCount( int ac )
      {   
        absenceCount = ac;
      }
    
      /** Returns the name of this Student. **/
      public String getName()  
      {  
        return name;
      }
    
      /** Returns the number of times this Student has missed class. **/
      public int getAbsenceCount() 
      {  
        return absenceCount;
      } 
    
      public String toString()
      {  
        return name + " " + absenceCount + " ";
      }
    }
    
    public class SeatingChart
    {
      /** seats[r][c] represents the Student in row r and column c in the classroom. **/
      private Student[][] seats; 
    
      /** Creates a seating chart with the given number of rows and columns from the students in 
       * studentList. Empty seats in the seating chart are represented by null.
       * @param rows the number of rows of seats in the classroom
       * @param cols the number of columns of seats in the classroom
       * Precondition:  rows > 0; cols > 0;
       * rows * cols >= studentList.size() 
       * Postcondition:
       * - Students appear in the seating chart in the same order as they appear
       * in studentList, starting at seats[0][0]. 
       * - seats is filled column by column from studentList, followed by any
       * empty seats (represented by null).
       * - studentList is unchanged.
       **/
      public SeatingChart(ArrayList<Student> studentList, int rows, int cols)
      {
        seats = new Student[rows][cols];
    
        int row = 0, col = 0;
        for (int i = 0; i < studentList.size(); i++)
        {
          seats[row][col] = studentList.get(i);
          row++;
          if (row == rows)
          {
            row = 0;
            col++;
          }
        }
      }
      void drawChart(ArrayList<Student> newSeatingChart)
      {
        //for (int i=0; i<6; i++) {
        //  for (int j=0; j<6; j++) {
        //    stroke(0);
        //    fill(255);
        //    rect(i*size, j*size, size, size);
        //    fill(0);
        //    stroke(0);
        //    text(newSeatingChart[i][j].name, i*size, j*size);
        //    text(newSeatingChart[i][j].absenceCount, i*size+40, j*size);
        //  }
        //}
        for (int i=0; i<6; i++) {
          for (int j=0; j<6; j++) {
            stroke(0);
            fill(255);
            rect(i*size, j*size, size, size);
            fill(0);
            stroke(0);
            text(newSeatingChart.get(i).name, i*size, j*size);
            text(newSeatingChart.get(i).absenceCount, i*size+40, j*size);
          }
        }
      }
    
    
      /** Removes students who have more than a given number of absences from the
       * seating chart, replacing those entries in the seating chart with null
       * and returns the number of students removed.
       * @param allowedAbsences an integer >= 0
       * @return number of students removed from seats
       * Postcondition:
       * - All students with allowedAbsences or fewer are in their original positions in seat
       * - No student in seats has more than allowedAbsences absences.
       * - Entries without students contain null.
       */
      public int removeAbsentStudents(int allowedAbsences,ArrayList<Student> l)
      {
        int removedCount = 0; 
        for (int r = 0; r < seats.length; r++)
        {
          for (int c = 0; c < seats[0].length; c++)
          {
            l.set(r, seats[r][c]);
            if (seats[r][c] != null && seats[r][c].getAbsenceCount() > allowedAbsences)
            {
              seats[r][c] = null;
              removedCount++;
            }
          }
        }
        return removedCount;
      }
    
      /** Rearrange students in the seating chart in alphabetical order
       * with a new set of rows and columns
       * and returns the new seating chart. The original seating chart
       * is not affected.
       * @param rows - may be different from the original number of rows
       * @param col - may be different from the original number of columns
       * Postcondition:
       * - All students with be in the new seating chart
       * - The original seating chart is the same
       */
      public Student[][] rearrangedStudents(int rows, int cols)
      {
        Student[][] updatedList=new Student[rows][cols];
        for (int i=0; i<seats[0].length; i++) {
          for (int j=0; j<seats.length; j++) {
            if (seats[i][j].name.charAt(0)<seats[i+1][j+1].name.charAt(0)) {
              seats[i][j]=seats[i+1][j+1];
              seats[i+1][j+1]=seats[i][j];
            }
          }
        }
        return updatedList;
      }
    
      public String toString()
      { 
        return "";
      }
    }
    
  • @gotoloop can you please correct my code

  • If I comment out apcs.removeAbsentStudents(1, roster);, your sketch works. :-\"

  • ok, so it is something wrong with that?

  • edited April 2016
    • It's too confusing, you've got a sketch field called roster and a SeatingChart field called seats.
    • The former is a List. While the latter is a 2d [][] array.
    • Strangely both refer to the same Student objects.
    • You're better off sticking to 1 only and getting rid of the other. 8-X
  • edited October 2016

    @gotoloop I updated the code entirely

    / ** Author: 
     * Date:  January 25, 2016
     * Description: This is a lab to create, manipulate and display
     *     a seating chart of students */
    
    /** The array/ArrayList of students in this lab is set up for you, along with the
     * setup and draw methods. Your job is to create the Student and SeatingChart classes,
     * which are described below. */
    
    ArrayList<Student> studentList;
    Student [] students = { new Student("Anderson", "John", 4.5, 4), new Student("Anderson", "Joe", 4.2, 3), 
      new Student("Brady", "Bob", 3.5, 2), new Student("Braxton", "Tina", 4.5, 2), 
      new Student("Alberts", "Abby", 4.2, 1), new Student("Carpenter", "Gina", 3.8, 5), 
      new Student("Ziebart", "Mike", 3.2, 3), new Student("Sampson", "Delilah", 3.2, 2), 
      new Student("Douglas", "Dilbert", 1.2, 30), new Student("Fudge", "Chocolate", 4.8, 0), 
      new Student("Tucker", "Tammy", 3.6, 2), new Student("Player", "Basketball", 3.4, 3), 
      new Student("Gina", "Gardenia", 3.6, 1), new Student("Rare", "Great", 4.9, 2), 
      new Student("Carlton", "Tom", 4.1, 2), new Student("Victory", "Dance", 2.1, 5), 
      new Student("Howdy", "Doody", 0.2, 8)};
    
    SeatingChart sc;
    int numRows = 4;
    int numCols = 5;
    int cellSize = 100;
    
    void setup()
    {
      size(500, 500);
      background(255);
    
      // loop and add array values to the ArrayList
    
      studentList = new ArrayList<Student>();
      for (int i = 0; i < students.length; i++)
        studentList.add(students[i]);
    
      sc = new SeatingChart(studentList, numRows, numCols);
    }
    
    void draw()
    {
    
      if (keyPressed)
      {
        if (key == 'a')
          sc.removeAbsentStudents(3);
        else if (key == 'g')
          sc.removeLowGPAStudents(3.4);
        else if (key == '0')
          sc.sortStudents(0);
        else if (key == '1')
          sc.sortStudents(1);
        else if (key == '2')
          sc.sortStudents(2);
        else if (key == 'd')
          sc.displaySeatingChart();
      }
    }
    
    /** Write the Student class, which should include:
     *    1. These fields: private String last, first (names), private double gpa and int numAbsences
     *    2. Write the Student constructor which sets these values
     *    3. Write these public accessor/modifier methods:
     *       a. getLast
     *       b. getFirst
     *       c. getGPA and setGPS
     *       d. getNumAbsences and setNumAbsences
     *    4. Write these compare methods that will be called in the sortStudents method
     *       a. compareToName(Student other)
     *       b. compareToGPA(Student other)
     *       c. comapreToNumAbsences(student other)
     */
    
    public class Student {
      private String fst, lst;
      private double gpa;
      private int numabs;
      public Student(String nm, String last, double gpaa, int numAbsences) {
        fst=nm;
        lst=last;
        gpa=gpaa;
        numabs=numAbsences;
      }
      String getLast() {
        return lst;
      }
      String getFirst() {
        return fst;
      }
      double getGPA() {
        return gpa;
      }
      double setGPSA(double gp) {
        gpa=gp;
        return gpa;
      }
      int getNumAbsences() {
        return numabs;
      }
      int setNumAbsences(int numabss) {
        numabs=numabss;
        return numabs;
      }
      int sortStudents(int method, Student other) {
        int ret=0;
        if (method==1) { //comparetoname
          if (this.getFirst().equals(other.getFirst())&&this.getLast().equals(other.getLast()))
            ret=0;
          else if ((this.getFirst().length()+this.getLast().length())<(other.getFirst().length()+other.getLast().length()))
            ret=-1;
          else
            ret=1;
        }
        if (method==2) {//compare gpa
          if (this.getGPA()==other.getGPA())
            ret= 0;
          else if (this.getGPA()<other.getGPA())
            ret= -1;
          else
            ret= 1;
        }
        if (method==3) { //numabs
          if (this.getNumAbsences()==other.getNumAbsences())
            ret= 0;
          else if (this.getNumAbsences()<other.getNumAbsences())
            ret=-1;
          else
            ret=1;
        }
        return ret;
      }
    }
    /* Now you need to write the SeatingChart class with the following specifications:
     *
     *    1. You will need one field: a 2D array of Student objects called "chart"
     *    2. A constructor which accepts an ArrayList of Student objects and the number of rows and
     *        columns of students. The constructor will set up the 2D array with the students from the
     *        given ArrayList
     *    3. The following methods:
     *        public void displaySeatingChart() // this displays the seating chart in column major order
     *        public void removeAbsentStudents(int maxAbsences) // removes students with >= maxAbsences from the chart
     *        public void removeLowGPAStudents(int minGPA) // removes students with < minGPA from the chart
     *        public void sortStudents(int howSort) // howSort = 0 sorts by name, howSort = 1 sorts by GPA and
     *                               // howSort = 2 sorts by numAbsences
     */
    public class SeatingChart {
      Student[][] seats;
      public SeatingChart(ArrayList<Student> studentList, int rows, int cols)
      {
        seats = new Student[rows][cols];
    
        int row = 0, col = 0;
        for (int i = 0; i < studentList.size (); i++)
        {
          seats[row][col] = studentList.get(i);
          row++;
          if (row == rows)
          {
            row = 0;
            col++;
          }
        }
      }
      public void displaySeatingChart() {
        for (int i=0; i<seats.length; i++) {
          for (int j=0; j<seats[0].length; j++) {
            stroke(0);
            fill(255);
            rect(i*100, j*100, 100, 100);
            fill(0);
            stroke(0);
            text(seats[i][j].getLast()+" ", i*100, j*100);
            text(seats[i][j].getNumAbsences()+" ", i*100+40, j*100);
          }
        }
      }
      public void removeAbsentStudents(int maxAbsences) {
        for (int r = 0; r < seats.length; r++)
        {
          for (int c = 0; c < seats[0].length; c++)
          {
            if (seats[r][c] != null && seats[r][c].getNumAbsences() > maxAbsences)
            {
              seats[r][c] = null;
            }
          }
        }
      }
      public void removeLowGPAStudents(float minGPA) {
        int removed=0;
        for (int i=0; i<seats.length; i++) {
          for (int j=0; j<seats[0].length; j++) {
            if (seats[i][j].getGPA()<minGPA&&seats[i][j]!=null)
              seats[i][j]=null;
            removed++;
          }
        }
        println(removed);
      }
      public void sortStudents(int method) { // howSort = 0 sorts by name, howSort = 1 sorts by GPA and howSort = 2 sorts by numAbsences
        if (method==0) //name
        {
          for (int r = 0; r < seats.length; r++)
          {
            for (int c = 0; c < seats[0].length; c++)
            {
              if (seats[r][c].getLast().charAt(0)>seats[r+1][c].getLast().charAt(0)) {
                seats[r][c]=seats[r+1][c];
                seats[r+1][c]=seats[r][c];
              }
            }
          }
        }
        if (method==1) //gpa
        {
          for (int r = 0; r < seats.length; r++)
          {
            for (int c = 0; c < seats[0].length; c++)
            {
              if (seats[r][c].getGPA()>seats[r+1][c].getGPA()) {
                seats[r][c]=seats[r+1][c];
                seats[r+1][c]=seats[r][c];
              }
            }
          }
        }
        if (method==2) //abs
        {
          for (int r = 0; r < seats.length; r++)
          {
            for (int c = 0; c < seats[0].length; c++)
            {
              if (seats[r][c].getNumAbsences()>seats[r+1][c].getNumAbsences()) {
                seats[r][c]=seats[r+1][c];
                seats[r+1][c]=seats[r][c];
              }
            }
          }
        }
      }
    }
    

    however, still a null pointer at the chart

  • Line Number?

    Use println to find the var that's causing this

  • it helps in line 166

    to insert -1

      for (int j=0; j<seats[0].length-1; j++) {
    

    not sure why though

    somehow, the array is smaller than you expect.

    maybe because lines 22 and 23?

Sign In or Register to comment.