Question: 1 public class Classroom 2.1 3 4 5 6 7 //Fields //One String to hold the teacher's name I/A Stringill pointer for the seating chart

1 public class Classroom 2.1 3 4 5 6 7 //Fields //One String to hold the teacher's name I/A Stringill pointer for the seating chart //--- private String teacher; private String[][] seatChart; //Currently pointing to nothing V/Constructor //Sets the two fields //The String(10) must be pointed to a String[]() with dimensions 'rows' and 'cols //NOTE: The String] now exists, but with nuli pointers. //--- public Classroon(String teacher, int rows, int cols) { } //-- //PUBLIC METHODS 9 le 11 12 13 14 15 16 - 17 18 19 20 21 22 23 24 25 26 27 28 29 3e 31 32 33 34 35 36 37 38 39 40 41 42 //Method: addName //@param: String (the name to add) //return: void I/Put the name in the seating chart in the first slot available (i.e. null) // If the seating chart is full (1.e. no null pointers), do nothing //Method: removeName 1/@param: String (the name to remove) 7/@return: boolean //If the name exists in the data structure, replace it with 'null' and return true. I/If the name does NOT exist, do nothing except return false. /Method: SwapNames 1/@paran: String (the first nane) 1/@param: String (the second nane) I/@return: void 1/Swap the two nanes in the data structure. //If one, or both, of the names do NOT exist, do nothing. 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 1/Method: private method getSeating Chart() - called by toString() 1/@paran: none 1/@return: String //Return a String represenation of the seating chart. 1/For null pointers, replace 'null with -empty. //use a tab between names on the same row. // Method: override tostring() -- DONE FOR YOU 1/@return: String V/Two things to print, like this example: 1/1. Teacher: Ms. Johnston 1/2. call this.getSeatingchart() to get the chart (a Strine) @Override public String toString() Strings - "Teacher + this.teacher: + " " + this.getSeatingchart(): return; > 62 64 65 66 67 //end class The Classroom Class 1 public class MyProgram extends Console Program 2.1 3 public void run() 4- 5 v/Create a Classroom object with 3 rows x 6 columns of students 6 Classroom roomi - new Classroom("Mr. Jugglecats", 3, 6); V/Print the Classroom object 9 1/System.out.println(room); 10 11 //rooni.addName("Taha"); 12 //rooni. addName("Varun"); 13 //room1.addName("Ramsey"); 14 //rooni. addName("Azzan"); 15 //roomi.addName("Jiya"); 16 17 I/Print the Classroom object 18 1/System.out.println(room); 19 ze //room1.addName("Josh"); 21 //room1.addName("Armaan"); 22 //room1.addName("Mariam"): 23 //rooni.addName("Al"); 24 //rooni. addName("Max"); 25 //room1.addName("Davide"); 26 //room1.addName("Zoe"); 27 7/rooml.addName("Shrey"); 28 //rooni.addName("Sharif"); 29 //rooni.addName("Yassine"); 3e //room1.addName("Parth"); 31 //roomi.addName("Adan"); 32 7/room1.addName("Rayane"); 33 34 //Print the Classroom object 35 1/System.out.println(room); 36 37 38 /Try removing names from the classroom 39 7/--- 40 //System.out.println("Davide removed: " + room.removeName("Davide)); 41 //System.out.println("Marian removed: + rooni.removeName("Maria")); //System.out.println("Davide renoved: " + roon.remove Nane ( "Davide")); 43 1/System.out.println("Corky removed: + roon.removeName("Corky")): 44 45 // Print the classroon object 46 //System.out.println(); 47 1/System.out.println(roomi): 48 1/Swap sone of the names ONLY if both names exist! 50 //roomi. swapNanes("Taha", "Zoe"): 51 I/roonl.swapanes("ohn", "Ramsey"); 52 1/rooni.swapNames("Zoe", "Ada"); 53 54 //Print the Classroon object 55 1/System.out.println(room): 56 57 Add nanes into the first empty slots 58 V/roon.add("George 59 1/room addName("Lizzy") 1/rooni.addName("Thomas); 61 52 Print the classroom object 63 1/System.out.println(rooni); 54 65 end run 66 67 W/end class 6 IMPLEMENT THE METHODS IN THE Classroom Class . You may call private helper methods if you need them Leave empty slots in the seating chart as 'null' please Do not fill them with "-empty-" that is just what it looks like when printed! . Teacher: Mr. Jugglecats - empty--empty--empty--empty- -empty--empty- -empty--empty- -empty--empty- -empty. -empty- - empty--empty. -empty--empty. empty. -empty. Teacher: Mr. Jugglecats Taha Varun Ramsey Azzam Diya -empty- -empty--empty- -empty. -empty--empty. -empty- -empty--empty. -empty. -empty--empty--empty- Josh Teacher: Mr. Jugglecats Taha Varun Ramsey Azzam Jiya Armaan Mariam Al Max Davide Zoe Shrey Sharif Yassine Parth Adam Rayane Davide removed: true Mariam removed: true Davide removed: false Corky removed: false Josh Teacher: Mr. Jugglecats Taha Varun Ramsey Azzam Jiya Armaan -empty- Al Max -empty- Zoe Shrey Sharif Yassine Parth Adam Rayane Teacher: Mr. Jugglecats Adam Varun Ramsey Azzan Jiya Josh Armaan -empty. Al Max -empty- Taha Shrey Sharif Yassine Parth Zoe Rayane Teacher: Mr. Jugglecats Adam Varun Ramsey Azzan Armaan George Al Max Lizzy Shrey Sharif Yassine Parth Jiya Josh Taha Zoe Rayane
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
