Let’s write a program for something like PowerSchool that helps organize a seating chart for students. There is a tester file at the page’s bottom.
First class : Student , from https://mrmonline.org/student-class/
This class mainly manages a 2-d array of student objects. Note: an empty seat in the chart will be designated by a null value.
private Student chart ; // rows and columns for where kids are
private String rosterName; //name of this roster
private String teacherName;
private int period ; //which period is this chart associated
public static final int DEFAULT_ROWS = 10;
public static final int DEFAULT_COLS = 10;
- public SeatingChart(int period, String teacher, String _rosterName) Initializes parameters to respective arguments and creates a 2-d array of null objects with default dimensions DEFAULT_ROWS , DEFAULT_COLS
- public SeatingChart(int period, String teacher, String _rosterName, Student table)
public int countEmptySeats() ; //returns the number of empty seats. As noted earlier, an empty seat is represented by a null value in the 2-d array of student s
Student getStudentChart() @returns chart
public int indexOf(Student stu); returns a 2 element array representing the row and column position of stu in chart ; [-1][-1] should be returned if stu is not in chart
public boolean setSeat(int row, int col, Student stu) - places Student Stu at that row and column . This can only be done if there is no student in that location. If a student already inhabits that row and column then the method should return false and not make any changes to chart .
public void swap(Student s1, Student s2) // this swaps the locations of s1 and s2
public Student getStudent(int row, int col) returns the student at the given row and col ; or null if the seat is empty
public void removeStudentAt(int row, int col) sets value of object at row and col to null
public boolean equals(SeatingChart other) // returns true if all aspects of other are equivalent to self.
public String toString(); //follow the conventions we have been using
public Student oldest() // returns the student object with the greatest age
public void randomize() // this randomizes the chart. This extra credit method is only available if you first meet with me to explain what I expect out of this.