SlideShare a Scribd company logo
1 of 13
Download to read offline
Please follow the instructions carefully as there are some specific conditions to the code. Do not
use pre-written code, none of them work. I need help with the last four methods only, starting
from moveStudentsFromChairToLine(). Thank you!
Classroom.java
package kindergarten;
/**
* This class represents a Classroom, with:
* - an SNode instance variable for students in line,
* - an SNode instance variable for musical chairs, pointing to the last student
* in the list,
* - a boolean array for seating availability (eg. can a student sit in a given
* seat), and
* - a Student array parallel to seatingAvailability to show students filed into
* seats
* --- (more formally, seatingAvailability[i][j] also refers to the same seat in
* studentsSitting[i][j])
*/
public class Classroom {
private SNode studentsInLine; // when students are in line: references the FIRST student in the
LL
private SNode musicalChairs; // when students are in musical chairs: references the LAST
student in the CLL
private boolean[][] seatingLocation; // represents the classroom seats that are available to
students
private Student[][] studentsSitting; // when students are sitting in the classroom: contains the
students
public Classroom(SNode l, SNode m, boolean[][] a, Student[][] s) {
studentsInLine = l;
musicalChairs = m;
seatingLocation = a;
studentsSitting = s;
}
/**
* This method simulates students standing in line and coming into the classroom
* (not leaving the line).
* It does this by reading students from input file and inserting these students
* studentsInLine singly linked list.
* 1. Open the file using StdIn.setFile(filename);
* 2. For each line of the input file:
* 1. read a student from the file
* 2. create an object of type Student with the student information
* 3. insert the Student object at the FRONT of the linked list
* Input file has:
* 1) one line containing an integer representing the number of students in the
* file, say x
* 2) x lines containing one student per line. Each line has the following
* student
* information separated by spaces: FirstName LastName Height
*
* To read a string using StdIn use StdIn.readString()
* The input file has Students in REVERSE alphabetical order. So, at the end of
* this
* method all students are in line in alphabetical order.
* DO NOT implement a sorting method, PRACTICE add to front.
* @param filename the student information input file
*/
public void enterClassroom(String filename) {
// WRITE YOUR CODE HERE
}
/**
* This method creates and initializes the seatingAvailability (2D array) of
* available seats inside the classroom. Imagine that unavailable seats are
* broken and cannot be used.
* 1. Open the file using StdIn.setFile(seatingChart);
* 2. You will read the seating chart input file with the format:
* An integer representing the number of rs in the classroom, say r
* An integer representing the number of cumns in the classroom, say c
* Number of r lines, each containing c true or false values (true represents
* that a seat is present in that cumn)
* 3. Initialize seatingLocation and studentsSitting arrays with r rs and c
* cumns
* 4. Update seatingLocation with the boolean values read from the input file
* This method does not seat students on the seats.
*/
public void setupSeats(String seatingChart) {
// WRITE YOUR CODE HERE
}
/**
*
* This method simulates students standing inline and then taking their seats in
* the classroom.
* 1. Starting from the front of the studentsInLine singly linked list
* 2. Remove one student at a time from the list and insert the student into
* studentsSitting according to
* seatingLocations
* studentsInLine will then be empty
* If the students just played musical chairs, the winner of musical chairs is
* seated separately
* by seatMusicalChairsWinner().
*/
public void seatStudents() {
// WRITE YOUR CODE HERE
}
/**
* Traverses studentsSitting r-wise (starting at r 0) removing a seated
* student and adding that student to the end of the musicalChairs list.
*
* row-wise: starts at index [0][0] traverses the entire first r and then
* moves
* into second r.
*/
public void insertMusicalChairs() {
// WRITE YOUR CODE HERE
}
/**
*
* Removes a random student from the musicalChairs.
*
* @param size represents the number of students currently sitting in
* musicalChairs
*
* 1. Select a random student to be removed from the musicalChairs
* CLL.
* 2. Searches for the selected student, deletes that student from
* musicalChairs
* 3. Calls insertByHeight to insert the deleted student into
* studentsInLine list.
*
* Requires the use of StdRandom.uniform(int b) to select a random
* student to remove,
* where b is the number of students currently sitting in the
* musicalChairs.
*
* The random value denotes the refers to the position of the
* student to be removed
* in the musicalChairs. 0 is the first student
*/
public void moveStudentFromChairsToLine(int size) {
// WRITE YOUR CODE HERE
}
/**
* Inserts a single student, eliminated from musical chairs, to the
* studentsInLine list.
* The student is inserted in ascending order by height (shortest to tallest).
*
* @param studentToInsert the student eliminated from chairs to be inserted into
* studentsInLine
*/
public void insertByHeight(Student studentToInsert) {
// WRITE YOUR CODE HERE
}
/**
* Removes eliminated students from the musicalChairs and inserts those students
* back in studentsInLine in ascending height order (shortest to tallest).
* At the end of this method, all students will be in studentsInLine besides
* the winner, who will be in musicalChairs alone.
* 1. Find the number of students currently on musicalChairs
* 2. While there are more than 1 student in musicalChairs, call
* moveRandomStudentFromChairsToLine()
*/
public void eliminateLosingStudents() {
// WRITE YOUR CODE HERE
}
/*
* If musicalChairs (circular linked list) contains ONLY ONE student (the
* winner),
* this method removes the winner from musicalChairs and inserts that student
* into the first available seat in studentsSitting. musicChairs will then be
* empty.
* This only happens when the musical chairs was just played.
* This methods does nothing if there is more than one student in musicalChairs
* or if musicalChairs is empty.
*/
public void seatMusicalChairsWinner() {
// WRITE YOUR CODE HERE
}
SNODE.Java
package kindergarten;
/**
* This class represents a student node, with a student
* object representing the student, and a next pointer
* for the student next in line.
*/
public class SNode {
private Student student; // the data part of the node
private SNode next; // a link to the next student int the linked list
public SNode ( Student s, SNode n ) {
student = s;
next = n;
}
public SNode() {
this(null, null);
}
public Student getStudent () { return student; }
public void setStudent (Student s) { student = s; }
public SNode getNext () { return next; }
public void setNext (SNode n) { next = n; }
}
Student.Java
/**
* This class represents a student, with a string variable for the
* student's name and an int variable for the student's height.
*/
public class Student {
private String firstName;
private String lastName;
private int height;
/*
* Constructor
*/
public Student ( String f, String l, int h ) {
firstName = f;
lastName = l;
height = h;
}
/*
* Default constructor sets student's height to 0 (zero)
*/
public Student () {
this(null, null, 0);
}
/**
* Compares the names of this student to paremeter student,
* returning an int value representing which name comes in first alphabetically.
*
* @param other the student being compared
*
* @return an int value of which name comes first alphabetically
* n < 0 means this student's name comes before parameter student
* n > 0 means parameter student's name comes before this student
*/
public int compareNameTo ( Student other ) {
int lastNameCompare = this.lastName.compareToIgnoreCase(other.getLastName());
if ( lastNameCompare == 0 ) {
// same last name, compare first names
return this.firstName.compareToIgnoreCase(other.getFirstName());
}
return lastNameCompare;
}
/* Getter and setter methods */
public String getFirstName () { return firstName; }
public void setFirstName ( String f ) { firstName = f; }
public String getLastName () { return lastName; }
public void setLastName ( String l ) { lastName = l; }
public int getHeight () { return height; }
public void setHeight ( int h ) { height = h; }
}
Overview In this assignment you will simulate activities in a kindergarten classroom. You will
simulate the students standing in a line, the students on their seats, and the students playing
musical chairs. The assignment uses: - a Singly Linked List to simulate student standing in a line.
- a 2D array to simulate students at their seats. - a Circular Linked List to simulate students
sitting on chairs to play the musical chairs game. A U array simulates students at their seats A
Circular Linked List simulates students sitting on chairs to play the musical chairs standing on a
line game Implementation Overview of files provided - Student class which holds a student's
information. - SNode class represents the node object to be used in the linked structures. It
contains a reference to a Student object and a reference to the next node in the list. - Classroom
class holds all of the methods to be written and that will be tested when running the game. Edit
the empty methods with you solution, but DO NOT edit the provided ones or the methods
signatures of any method. This is the file you submit. - Driver class, which is used to test your
methods interactively. The classroom state will be printed after every method is used. Feel free
to edit this file, as it is provided only to help you test your code. It is not submitted and it is not
used to grade your code. - StdRandom class contains the StdRandom.uniform ( n ) method that
you will use in the method that plays the musical chairs game. - Stdln and StdOut, which are
used by the driver. Do not edit these classes.. - Multiple text files. Feel free to edit them or even
make new ones to help test your code. They are not submitted. - Files containing student
information. - Files containing seat location in the classroom. - DO NOT add new import
statements. - DO NOT change any of the method's signatures. - You are encouraged to write
helper methods as you see fit. Just make sure that they are private. The class contains: -
studentlnLine which refers to the first student in the singly linked list. - musicalChairs which
refers to the LAST student in the circularly linked list when the game is being played. -
seatingLocation which is a 2 D boolean array that shows which seats exist for students to seat at.
- students Sitting which is a 2D Student array that contains the students when they are sitting. -
NOTE: seatingLocation and studentsSitting are parallel arrays meaning that seatingLocation[i][i]
also refers to the same seat in students Sitting[i][i] - provided methods that are used by the driver
and empty methods you are expected to write your code in. - the printClassroom() function can
be used to show the state of the classroom (eg. the states of students in line, seating, and musical
chairs) at any time in your code. The input file has Students in reverse alphabetical order; so at
the end of this method the list will have all students in alphabetical order. DO NOT implement a
sorting algorithm, there is no need. - Submit Classroom.java with this method completed under
Early Submission to receive extra credit. This is the expected output for students 1 in Students in
Line: M. Brow N. Dyer P. Ferg D. Harb M. Hawk C. Heat J. Keer G. Mata . MCLa M. Modi D.
Mont P. Reis W. Ryde N. Schn S. Sink F. Wolf Sitting Students: EMPTY Students in Musical
Chairs: EMPTY What would you like to do now? 1. Test a new input file 2. Test another method
on the same file 3. Quit Enter a number 2. setupseats This method creates the classroom seats.
Imagine that someone is putting down seats on a rectangular or square room. - We will use a 2 D
array to simulate a room where each cell of the array can have a seat or not. - The instance
variable seatingLocations is the 2D boolean array that shows which seats exist for students to
seat at. - The instance variable students Sitting is the 2D array that contains the students when
they are seating. To complete complete this method do: 1. Read the input file to create the
seating arrangement for 2 D boolean array seatingLocations 2. Initialize the 2D Student array
students Sitting to be of the same size. The input file format is as follows: - The first line
contains an integer representing the number of rows in the classroom, say r - The second line
contains an integer representing the number of columns in the classroom, say c - Number of r
lines, each containing c true or false values (true denotes a seat exists, false denotes that there is
no seat at that position in the classroom) Use the Stdln library to read from a file: -
stdin.setfile(filename) opens a file to be read - stdin. readint() reads the next integer value from
the opened file (weather the value is in the current line or in the next line) - stdin.readboolean()
read the next boolean value from the opened file (weather the value is in the current line or in the
next line) This method DOES NOT seat students on the seats. This is the expected output for
students1.in and seating 1 in: 3. seatStudents This method simulates students taking their seats in
the Kindergarten classroom. Assume that the students are currently in studentsinLine and that
there are enough available seats to seat all students in the line. - This method will populate the
2D array students Sitting. - Students will be seated starting at the first row, first seat
(studentsSitting[0][0] if a seat is present at that location). Once the first row is filled, continues
into the next row. - It uses the seatingLocations array to determine if a seat exists at a location. -
A student can sit at seat students Sitting[i][j] only if seatingLocations[i][i] is true (seat exists). -
Then seat the first student in studentsinLine and moves on to the second, third and so on.
NOTES - A student is only in one place (musical chairs, seating chairs, or in line) at a time. At
the end of this method studentsinLine is empty. - This method depends on enterClassroom and
setupSeats. Test those individually on the driver prior to testing this method. 4.
insertMusicalChairs This method represents students preparing to start musical chairs! Assume
that the students are in studentssitting. - Imagine this as a circle of chairs. - This method will take
students from the students Sitting array and add them to the musicalChairs circular linked list. -
Students are to be inserted at the end of the linked list by traversing row-wise, then column-wise
in the studentsSitting array. - REMEMBER: the pointer to a circular linked list points to the
LAST item in the list, and that item points to the front. NOTES - At the end of this method
studentsinLine and students Sitting have no students. - This method depends on the previous
methods from parts 1,2 , and 3 . Test those before testing insertMusicalChairs. This is the
expected output using students1.in and seating 1 in: playMusicalChairs This method simulates
the game of musical chairs! - This method is implemented for you. - Write the following
methods to make it work. This is the expected output using students1.in and seating 1 .in: 5.
moveStudentFromChairs ToLine This method simulates a student being eliminated during the
musical chairs game. - This method randomly chooses a student to be eliminated from
musicalChairs. - Use StdRandom.uniform ( x ) , where x is the number of students currently in
musicalChairs, to get a number n between 0 (inclusive) and x (exclusive). - Remove the student
at position n from musicalChairs. Position 0 is the first student. - Notice that the driver is setting
a seed for the random number generator. The seed value is 2022. - Once the student is removed
from the chairs call insertByHeight to insert the student into studentsInLine. - Watch this video
for more information. Note: this method depends on insertMusicalChairs and insertByHeight.
Students in Musical Chairs: M. Brow N. Dyer P. Ferg D. Harb M. Hawk C. Heat J. Keer G. Mata
C. McLa D. Mont P. Reis W. Ryde N. Schn S. Sink F. Wolf - POINTS TO FRONT 6.
insertByHeight Each student that is eliminated from the musical chairs game is put back in the
line (studentsinLine linked list) by height order. - The eliminated student is given as as parameter
- Iterate through studentsinLine searching for a student that is taller than the eliminated student.
You will have 3 cases: - eliminated student is the shortest, insert at the front of the list. -
eliminated student is the tallest, insert at the end of the list. - eliminated student is not the shortest
or tallest, insert in the middle of the list. - When inserting into the list, a student will be insert
AFTER all students of the same height. - Watch this video for more information. - This method
is called from moveStudentFromChairs ToLine() to insert a student that was eliminated from the
musical chairs game. In the driver, you can test this method independently using
moveStudentFromChairsToLine. 7. eliminateLosingStudents This method eliminates all students
from musicalChairs except the winner. 1. Obtain the number of students currently in the
musicalChairs, call it size. 2. Repeatedly call moveRandom StudentFromChairs ToLine with the
size until one player is left. 3. Don't forget to update size after each call as the number of students
in the chairs decreases by 1. At the end of this method one student will remain in musicalChairs,
this is the winner! The winner doesn't leave the musical chairs to enter the line. All other
students will be standing on the line in ascending order by height. NOTE: this method depends
on all previous methods. 8. seatMusicalChairsWinner This method will seat the winner of the
musical chairs game! After the game of playMusicalChairs, you must seat the winner first! - If
musical musicalChairs contains only one node (that is, the winner), delete the node. The list will
be empty. - Insert the student object into the first empty spot in the classroom (seatingStudents).
Implementation Notes - YOU MAY only update the methods with the WRITE YOUR CODE
HERE line. - DO NOT add any instance variables to the Classroom class. - DO NOT add any
public methods to the Classroom class. - YOU MAY add private methods to the Classroom
class. - DO NOT use System exit()

More Related Content

Similar to Please follow the instructions carefully as there are some specific co.pdf

03_Objects and Classes in java.pdf
03_Objects and Classes in java.pdf03_Objects and Classes in java.pdf
03_Objects and Classes in java.pdfParameshwar Maddela
 
In Java- Create a Graduate class derived from Student- A graduate has.pdf
In Java- Create a Graduate class derived from Student- A graduate has.pdfIn Java- Create a Graduate class derived from Student- A graduate has.pdf
In Java- Create a Graduate class derived from Student- A graduate has.pdfStewart29UReesa
 
Core java concepts
Core java concepts Core java concepts
Core java concepts javeed_mhd
 
COSC 2436 – PROJECT Contents TITLE ..................docx
COSC 2436 – PROJECT Contents TITLE ..................docxCOSC 2436 – PROJECT Contents TITLE ..................docx
COSC 2436 – PROJECT Contents TITLE ..................docxbobbywlane695641
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfcontact41
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfarrowvisionoptics
 
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdfTeacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdfkareemangels
 
#ifndef COURSES_H #define COURSES_H class Courses { privat.pdf
#ifndef COURSES_H #define COURSES_H class Courses { privat.pdf#ifndef COURSES_H #define COURSES_H class Courses { privat.pdf
#ifndef COURSES_H #define COURSES_H class Courses { privat.pdfanupambedcovers
 

Similar to Please follow the instructions carefully as there are some specific co.pdf (10)

03_Objects and Classes in java.pdf
03_Objects and Classes in java.pdf03_Objects and Classes in java.pdf
03_Objects and Classes in java.pdf
 
In Java- Create a Graduate class derived from Student- A graduate has.pdf
In Java- Create a Graduate class derived from Student- A graduate has.pdfIn Java- Create a Graduate class derived from Student- A graduate has.pdf
In Java- Create a Graduate class derived from Student- A graduate has.pdf
 
Core java concepts
Core java concepts Core java concepts
Core java concepts
 
Core java
Core javaCore java
Core java
 
COSC 2436 – PROJECT Contents TITLE ..................docx
COSC 2436 – PROJECT Contents TITLE ..................docxCOSC 2436 – PROJECT Contents TITLE ..................docx
COSC 2436 – PROJECT Contents TITLE ..................docx
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdf
 
Static Members-Java.pptx
Static Members-Java.pptxStatic Members-Java.pptx
Static Members-Java.pptx
 
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdfTeacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
 
#ifndef COURSES_H #define COURSES_H class Courses { privat.pdf
#ifndef COURSES_H #define COURSES_H class Courses { privat.pdf#ifndef COURSES_H #define COURSES_H class Courses { privat.pdf
#ifndef COURSES_H #define COURSES_H class Courses { privat.pdf
 

More from Ian5L3Allanm

Please write a C++ program to (1) Generate the following pattern using.pdf
Please write a C++ program to (1) Generate the following pattern using.pdfPlease write a C++ program to (1) Generate the following pattern using.pdf
Please write a C++ program to (1) Generate the following pattern using.pdfIan5L3Allanm
 
please solve part (C) only- Thanks The following information was taken.pdf
please solve part (C) only- Thanks The following information was taken.pdfplease solve part (C) only- Thanks The following information was taken.pdf
please solve part (C) only- Thanks The following information was taken.pdfIan5L3Allanm
 
Please provide a short answer to the image! Analyze this Karyotype as.pdf
Please provide a short answer to the image!  Analyze this Karyotype as.pdfPlease provide a short answer to the image!  Analyze this Karyotype as.pdf
Please provide a short answer to the image! Analyze this Karyotype as.pdfIan5L3Allanm
 
Please illustrate the differences between Variable Costing system vers.pdf
Please illustrate the differences between Variable Costing system vers.pdfPlease illustrate the differences between Variable Costing system vers.pdf
Please illustrate the differences between Variable Costing system vers.pdfIan5L3Allanm
 
please follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdfplease follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdfIan5L3Allanm
 
Please complete and post the screenshots here- I can be reached at pra.pdf
Please complete and post the screenshots here- I can be reached at pra.pdfPlease complete and post the screenshots here- I can be reached at pra.pdf
Please complete and post the screenshots here- I can be reached at pra.pdfIan5L3Allanm
 
Please answer it appropriately- I have already uploaded and the expert.pdf
Please answer it appropriately- I have already uploaded and the expert.pdfPlease answer it appropriately- I have already uploaded and the expert.pdf
Please answer it appropriately- I have already uploaded and the expert.pdfIan5L3Allanm
 
please answer these two questions briefly thank you Examine Figures 1.pdf
please answer these two questions briefly  thank you Examine Figures 1.pdfplease answer these two questions briefly  thank you Examine Figures 1.pdf
please answer these two questions briefly thank you Examine Figures 1.pdfIan5L3Allanm
 
Phonology- infants start to produce sounds as soon as they are born (c.pdf
Phonology- infants start to produce sounds as soon as they are born (c.pdfPhonology- infants start to produce sounds as soon as they are born (c.pdf
Phonology- infants start to produce sounds as soon as they are born (c.pdfIan5L3Allanm
 
Phenylketonuria (PKU) is a autosomal recessive disorder in which a per.pdf
Phenylketonuria (PKU) is a autosomal recessive disorder in which a per.pdfPhenylketonuria (PKU) is a autosomal recessive disorder in which a per.pdf
Phenylketonuria (PKU) is a autosomal recessive disorder in which a per.pdfIan5L3Allanm
 
Please answer the following questions- Question #1- Which of the follo.pdf
Please answer the following questions- Question #1- Which of the follo.pdfPlease answer the following questions- Question #1- Which of the follo.pdf
Please answer the following questions- Question #1- Which of the follo.pdfIan5L3Allanm
 
Please help me solve this problem entirely - I really appreciate it- T (5).pdf
Please help me solve this problem entirely - I really appreciate it- T (5).pdfPlease help me solve this problem entirely - I really appreciate it- T (5).pdf
Please help me solve this problem entirely - I really appreciate it- T (5).pdfIan5L3Allanm
 
Please help me solve the above 2 questions- I will drop a thumbs up fo.pdf
Please help me solve the above 2 questions- I will drop a thumbs up fo.pdfPlease help me solve the above 2 questions- I will drop a thumbs up fo.pdf
Please help me solve the above 2 questions- I will drop a thumbs up fo.pdfIan5L3Allanm
 
Please help me i will give good rating Hanan works for a Korean multi.pdf
Please help me i will give good rating  Hanan works for a Korean multi.pdfPlease help me i will give good rating  Hanan works for a Korean multi.pdf
Please help me i will give good rating Hanan works for a Korean multi.pdfIan5L3Allanm
 
Please answer the following questions thoroughly- 1) What are the m.pdf
Please answer the following questions thoroughly-    1) What are the m.pdfPlease answer the following questions thoroughly-    1) What are the m.pdf
Please answer the following questions thoroughly- 1) What are the m.pdfIan5L3Allanm
 
photosythesis - chromatography paper- separation of photosynthetic pig.pdf
photosythesis - chromatography paper- separation of photosynthetic pig.pdfphotosythesis - chromatography paper- separation of photosynthetic pig.pdf
photosythesis - chromatography paper- separation of photosynthetic pig.pdfIan5L3Allanm
 
Please explain what this means -The overall model was statistically si.pdf
Please explain what this means -The overall model was statistically si.pdfPlease explain what this means -The overall model was statistically si.pdf
Please explain what this means -The overall model was statistically si.pdfIan5L3Allanm
 
Please draw an evolutionary tree dthe information given- 3- A new or.pdf
Please draw an evolutionary tree dthe information given-   3- A new or.pdfPlease draw an evolutionary tree dthe information given-   3- A new or.pdf
Please draw an evolutionary tree dthe information given- 3- A new or.pdfIan5L3Allanm
 
Please complete the following App using Parallel Arrays- -- -- Conte.pdf
Please complete the following App using Parallel Arrays-  -- --  Conte.pdfPlease complete the following App using Parallel Arrays-  -- --  Conte.pdf
Please complete the following App using Parallel Arrays- -- -- Conte.pdfIan5L3Allanm
 
Phagocytes ingest particular matter into cells for degradation- Which.pdf
Phagocytes ingest particular matter into cells for degradation- Which.pdfPhagocytes ingest particular matter into cells for degradation- Which.pdf
Phagocytes ingest particular matter into cells for degradation- Which.pdfIan5L3Allanm
 

More from Ian5L3Allanm (20)

Please write a C++ program to (1) Generate the following pattern using.pdf
Please write a C++ program to (1) Generate the following pattern using.pdfPlease write a C++ program to (1) Generate the following pattern using.pdf
Please write a C++ program to (1) Generate the following pattern using.pdf
 
please solve part (C) only- Thanks The following information was taken.pdf
please solve part (C) only- Thanks The following information was taken.pdfplease solve part (C) only- Thanks The following information was taken.pdf
please solve part (C) only- Thanks The following information was taken.pdf
 
Please provide a short answer to the image! Analyze this Karyotype as.pdf
Please provide a short answer to the image!  Analyze this Karyotype as.pdfPlease provide a short answer to the image!  Analyze this Karyotype as.pdf
Please provide a short answer to the image! Analyze this Karyotype as.pdf
 
Please illustrate the differences between Variable Costing system vers.pdf
Please illustrate the differences between Variable Costing system vers.pdfPlease illustrate the differences between Variable Costing system vers.pdf
Please illustrate the differences between Variable Costing system vers.pdf
 
please follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdfplease follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdf
 
Please complete and post the screenshots here- I can be reached at pra.pdf
Please complete and post the screenshots here- I can be reached at pra.pdfPlease complete and post the screenshots here- I can be reached at pra.pdf
Please complete and post the screenshots here- I can be reached at pra.pdf
 
Please answer it appropriately- I have already uploaded and the expert.pdf
Please answer it appropriately- I have already uploaded and the expert.pdfPlease answer it appropriately- I have already uploaded and the expert.pdf
Please answer it appropriately- I have already uploaded and the expert.pdf
 
please answer these two questions briefly thank you Examine Figures 1.pdf
please answer these two questions briefly  thank you Examine Figures 1.pdfplease answer these two questions briefly  thank you Examine Figures 1.pdf
please answer these two questions briefly thank you Examine Figures 1.pdf
 
Phonology- infants start to produce sounds as soon as they are born (c.pdf
Phonology- infants start to produce sounds as soon as they are born (c.pdfPhonology- infants start to produce sounds as soon as they are born (c.pdf
Phonology- infants start to produce sounds as soon as they are born (c.pdf
 
Phenylketonuria (PKU) is a autosomal recessive disorder in which a per.pdf
Phenylketonuria (PKU) is a autosomal recessive disorder in which a per.pdfPhenylketonuria (PKU) is a autosomal recessive disorder in which a per.pdf
Phenylketonuria (PKU) is a autosomal recessive disorder in which a per.pdf
 
Please answer the following questions- Question #1- Which of the follo.pdf
Please answer the following questions- Question #1- Which of the follo.pdfPlease answer the following questions- Question #1- Which of the follo.pdf
Please answer the following questions- Question #1- Which of the follo.pdf
 
Please help me solve this problem entirely - I really appreciate it- T (5).pdf
Please help me solve this problem entirely - I really appreciate it- T (5).pdfPlease help me solve this problem entirely - I really appreciate it- T (5).pdf
Please help me solve this problem entirely - I really appreciate it- T (5).pdf
 
Please help me solve the above 2 questions- I will drop a thumbs up fo.pdf
Please help me solve the above 2 questions- I will drop a thumbs up fo.pdfPlease help me solve the above 2 questions- I will drop a thumbs up fo.pdf
Please help me solve the above 2 questions- I will drop a thumbs up fo.pdf
 
Please help me i will give good rating Hanan works for a Korean multi.pdf
Please help me i will give good rating  Hanan works for a Korean multi.pdfPlease help me i will give good rating  Hanan works for a Korean multi.pdf
Please help me i will give good rating Hanan works for a Korean multi.pdf
 
Please answer the following questions thoroughly- 1) What are the m.pdf
Please answer the following questions thoroughly-    1) What are the m.pdfPlease answer the following questions thoroughly-    1) What are the m.pdf
Please answer the following questions thoroughly- 1) What are the m.pdf
 
photosythesis - chromatography paper- separation of photosynthetic pig.pdf
photosythesis - chromatography paper- separation of photosynthetic pig.pdfphotosythesis - chromatography paper- separation of photosynthetic pig.pdf
photosythesis - chromatography paper- separation of photosynthetic pig.pdf
 
Please explain what this means -The overall model was statistically si.pdf
Please explain what this means -The overall model was statistically si.pdfPlease explain what this means -The overall model was statistically si.pdf
Please explain what this means -The overall model was statistically si.pdf
 
Please draw an evolutionary tree dthe information given- 3- A new or.pdf
Please draw an evolutionary tree dthe information given-   3- A new or.pdfPlease draw an evolutionary tree dthe information given-   3- A new or.pdf
Please draw an evolutionary tree dthe information given- 3- A new or.pdf
 
Please complete the following App using Parallel Arrays- -- -- Conte.pdf
Please complete the following App using Parallel Arrays-  -- --  Conte.pdfPlease complete the following App using Parallel Arrays-  -- --  Conte.pdf
Please complete the following App using Parallel Arrays- -- -- Conte.pdf
 
Phagocytes ingest particular matter into cells for degradation- Which.pdf
Phagocytes ingest particular matter into cells for degradation- Which.pdfPhagocytes ingest particular matter into cells for degradation- Which.pdf
Phagocytes ingest particular matter into cells for degradation- Which.pdf
 

Recently uploaded

Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Please follow the instructions carefully as there are some specific co.pdf

  • 1. Please follow the instructions carefully as there are some specific conditions to the code. Do not use pre-written code, none of them work. I need help with the last four methods only, starting from moveStudentsFromChairToLine(). Thank you! Classroom.java package kindergarten; /** * This class represents a Classroom, with: * - an SNode instance variable for students in line, * - an SNode instance variable for musical chairs, pointing to the last student * in the list, * - a boolean array for seating availability (eg. can a student sit in a given * seat), and * - a Student array parallel to seatingAvailability to show students filed into * seats * --- (more formally, seatingAvailability[i][j] also refers to the same seat in * studentsSitting[i][j]) */ public class Classroom { private SNode studentsInLine; // when students are in line: references the FIRST student in the LL private SNode musicalChairs; // when students are in musical chairs: references the LAST student in the CLL private boolean[][] seatingLocation; // represents the classroom seats that are available to students private Student[][] studentsSitting; // when students are sitting in the classroom: contains the students
  • 2. public Classroom(SNode l, SNode m, boolean[][] a, Student[][] s) { studentsInLine = l; musicalChairs = m; seatingLocation = a; studentsSitting = s; } /** * This method simulates students standing in line and coming into the classroom * (not leaving the line). * It does this by reading students from input file and inserting these students * studentsInLine singly linked list. * 1. Open the file using StdIn.setFile(filename); * 2. For each line of the input file: * 1. read a student from the file * 2. create an object of type Student with the student information * 3. insert the Student object at the FRONT of the linked list * Input file has: * 1) one line containing an integer representing the number of students in the * file, say x * 2) x lines containing one student per line. Each line has the following * student * information separated by spaces: FirstName LastName Height *
  • 3. * To read a string using StdIn use StdIn.readString() * The input file has Students in REVERSE alphabetical order. So, at the end of * this * method all students are in line in alphabetical order. * DO NOT implement a sorting method, PRACTICE add to front. * @param filename the student information input file */ public void enterClassroom(String filename) { // WRITE YOUR CODE HERE } /** * This method creates and initializes the seatingAvailability (2D array) of * available seats inside the classroom. Imagine that unavailable seats are * broken and cannot be used. * 1. Open the file using StdIn.setFile(seatingChart); * 2. You will read the seating chart input file with the format: * An integer representing the number of rs in the classroom, say r * An integer representing the number of cumns in the classroom, say c * Number of r lines, each containing c true or false values (true represents * that a seat is present in that cumn) * 3. Initialize seatingLocation and studentsSitting arrays with r rs and c * cumns * 4. Update seatingLocation with the boolean values read from the input file
  • 4. * This method does not seat students on the seats. */ public void setupSeats(String seatingChart) { // WRITE YOUR CODE HERE } /** * * This method simulates students standing inline and then taking their seats in * the classroom. * 1. Starting from the front of the studentsInLine singly linked list * 2. Remove one student at a time from the list and insert the student into * studentsSitting according to * seatingLocations * studentsInLine will then be empty * If the students just played musical chairs, the winner of musical chairs is * seated separately * by seatMusicalChairsWinner(). */ public void seatStudents() { // WRITE YOUR CODE HERE } /** * Traverses studentsSitting r-wise (starting at r 0) removing a seated
  • 5. * student and adding that student to the end of the musicalChairs list. * * row-wise: starts at index [0][0] traverses the entire first r and then * moves * into second r. */ public void insertMusicalChairs() { // WRITE YOUR CODE HERE } /** * * Removes a random student from the musicalChairs. * * @param size represents the number of students currently sitting in * musicalChairs * * 1. Select a random student to be removed from the musicalChairs * CLL. * 2. Searches for the selected student, deletes that student from * musicalChairs * 3. Calls insertByHeight to insert the deleted student into * studentsInLine list. *
  • 6. * Requires the use of StdRandom.uniform(int b) to select a random * student to remove, * where b is the number of students currently sitting in the * musicalChairs. * * The random value denotes the refers to the position of the * student to be removed * in the musicalChairs. 0 is the first student */ public void moveStudentFromChairsToLine(int size) { // WRITE YOUR CODE HERE } /** * Inserts a single student, eliminated from musical chairs, to the * studentsInLine list. * The student is inserted in ascending order by height (shortest to tallest). * * @param studentToInsert the student eliminated from chairs to be inserted into * studentsInLine */ public void insertByHeight(Student studentToInsert) { // WRITE YOUR CODE HERE }
  • 7. /** * Removes eliminated students from the musicalChairs and inserts those students * back in studentsInLine in ascending height order (shortest to tallest). * At the end of this method, all students will be in studentsInLine besides * the winner, who will be in musicalChairs alone. * 1. Find the number of students currently on musicalChairs * 2. While there are more than 1 student in musicalChairs, call * moveRandomStudentFromChairsToLine() */ public void eliminateLosingStudents() { // WRITE YOUR CODE HERE } /* * If musicalChairs (circular linked list) contains ONLY ONE student (the * winner), * this method removes the winner from musicalChairs and inserts that student * into the first available seat in studentsSitting. musicChairs will then be * empty. * This only happens when the musical chairs was just played. * This methods does nothing if there is more than one student in musicalChairs * or if musicalChairs is empty. */ public void seatMusicalChairsWinner() {
  • 8. // WRITE YOUR CODE HERE } SNODE.Java package kindergarten; /** * This class represents a student node, with a student * object representing the student, and a next pointer * for the student next in line. */ public class SNode { private Student student; // the data part of the node private SNode next; // a link to the next student int the linked list public SNode ( Student s, SNode n ) { student = s; next = n; } public SNode() { this(null, null); } public Student getStudent () { return student; } public void setStudent (Student s) { student = s; } public SNode getNext () { return next; } public void setNext (SNode n) { next = n; }
  • 9. } Student.Java /** * This class represents a student, with a string variable for the * student's name and an int variable for the student's height. */ public class Student { private String firstName; private String lastName; private int height; /* * Constructor */ public Student ( String f, String l, int h ) { firstName = f; lastName = l; height = h; } /* * Default constructor sets student's height to 0 (zero) */ public Student () { this(null, null, 0);
  • 10. } /** * Compares the names of this student to paremeter student, * returning an int value representing which name comes in first alphabetically. * * @param other the student being compared * * @return an int value of which name comes first alphabetically * n < 0 means this student's name comes before parameter student * n > 0 means parameter student's name comes before this student */ public int compareNameTo ( Student other ) { int lastNameCompare = this.lastName.compareToIgnoreCase(other.getLastName()); if ( lastNameCompare == 0 ) { // same last name, compare first names return this.firstName.compareToIgnoreCase(other.getFirstName()); } return lastNameCompare; } /* Getter and setter methods */ public String getFirstName () { return firstName; } public void setFirstName ( String f ) { firstName = f; } public String getLastName () { return lastName; }
  • 11. public void setLastName ( String l ) { lastName = l; } public int getHeight () { return height; } public void setHeight ( int h ) { height = h; } } Overview In this assignment you will simulate activities in a kindergarten classroom. You will simulate the students standing in a line, the students on their seats, and the students playing musical chairs. The assignment uses: - a Singly Linked List to simulate student standing in a line. - a 2D array to simulate students at their seats. - a Circular Linked List to simulate students sitting on chairs to play the musical chairs game. A U array simulates students at their seats A Circular Linked List simulates students sitting on chairs to play the musical chairs standing on a line game Implementation Overview of files provided - Student class which holds a student's information. - SNode class represents the node object to be used in the linked structures. It contains a reference to a Student object and a reference to the next node in the list. - Classroom class holds all of the methods to be written and that will be tested when running the game. Edit the empty methods with you solution, but DO NOT edit the provided ones or the methods signatures of any method. This is the file you submit. - Driver class, which is used to test your methods interactively. The classroom state will be printed after every method is used. Feel free to edit this file, as it is provided only to help you test your code. It is not submitted and it is not used to grade your code. - StdRandom class contains the StdRandom.uniform ( n ) method that you will use in the method that plays the musical chairs game. - Stdln and StdOut, which are used by the driver. Do not edit these classes.. - Multiple text files. Feel free to edit them or even make new ones to help test your code. They are not submitted. - Files containing student information. - Files containing seat location in the classroom. - DO NOT add new import statements. - DO NOT change any of the method's signatures. - You are encouraged to write helper methods as you see fit. Just make sure that they are private. The class contains: - studentlnLine which refers to the first student in the singly linked list. - musicalChairs which refers to the LAST student in the circularly linked list when the game is being played. - seatingLocation which is a 2 D boolean array that shows which seats exist for students to seat at. - students Sitting which is a 2D Student array that contains the students when they are sitting. - NOTE: seatingLocation and studentsSitting are parallel arrays meaning that seatingLocation[i][i] also refers to the same seat in students Sitting[i][i] - provided methods that are used by the driver and empty methods you are expected to write your code in. - the printClassroom() function can be used to show the state of the classroom (eg. the states of students in line, seating, and musical chairs) at any time in your code. The input file has Students in reverse alphabetical order; so at the end of this method the list will have all students in alphabetical order. DO NOT implement a sorting algorithm, there is no need. - Submit Classroom.java with this method completed under Early Submission to receive extra credit. This is the expected output for students 1 in Students in Line: M. Brow N. Dyer P. Ferg D. Harb M. Hawk C. Heat J. Keer G. Mata . MCLa M. Modi D. Mont P. Reis W. Ryde N. Schn S. Sink F. Wolf Sitting Students: EMPTY Students in Musical Chairs: EMPTY What would you like to do now? 1. Test a new input file 2. Test another method on the same file 3. Quit Enter a number 2. setupseats This method creates the classroom seats. Imagine that someone is putting down seats on a rectangular or square room. - We will use a 2 D
  • 12. array to simulate a room where each cell of the array can have a seat or not. - The instance variable seatingLocations is the 2D boolean array that shows which seats exist for students to seat at. - The instance variable students Sitting is the 2D array that contains the students when they are seating. To complete complete this method do: 1. Read the input file to create the seating arrangement for 2 D boolean array seatingLocations 2. Initialize the 2D Student array students Sitting to be of the same size. The input file format is as follows: - The first line contains an integer representing the number of rows in the classroom, say r - The second line contains an integer representing the number of columns in the classroom, say c - Number of r lines, each containing c true or false values (true denotes a seat exists, false denotes that there is no seat at that position in the classroom) Use the Stdln library to read from a file: - stdin.setfile(filename) opens a file to be read - stdin. readint() reads the next integer value from the opened file (weather the value is in the current line or in the next line) - stdin.readboolean() read the next boolean value from the opened file (weather the value is in the current line or in the next line) This method DOES NOT seat students on the seats. This is the expected output for students1.in and seating 1 in: 3. seatStudents This method simulates students taking their seats in the Kindergarten classroom. Assume that the students are currently in studentsinLine and that there are enough available seats to seat all students in the line. - This method will populate the 2D array students Sitting. - Students will be seated starting at the first row, first seat (studentsSitting[0][0] if a seat is present at that location). Once the first row is filled, continues into the next row. - It uses the seatingLocations array to determine if a seat exists at a location. - A student can sit at seat students Sitting[i][j] only if seatingLocations[i][i] is true (seat exists). - Then seat the first student in studentsinLine and moves on to the second, third and so on. NOTES - A student is only in one place (musical chairs, seating chairs, or in line) at a time. At the end of this method studentsinLine is empty. - This method depends on enterClassroom and setupSeats. Test those individually on the driver prior to testing this method. 4. insertMusicalChairs This method represents students preparing to start musical chairs! Assume that the students are in studentssitting. - Imagine this as a circle of chairs. - This method will take students from the students Sitting array and add them to the musicalChairs circular linked list. - Students are to be inserted at the end of the linked list by traversing row-wise, then column-wise in the studentsSitting array. - REMEMBER: the pointer to a circular linked list points to the LAST item in the list, and that item points to the front. NOTES - At the end of this method studentsinLine and students Sitting have no students. - This method depends on the previous methods from parts 1,2 , and 3 . Test those before testing insertMusicalChairs. This is the expected output using students1.in and seating 1 in: playMusicalChairs This method simulates the game of musical chairs! - This method is implemented for you. - Write the following methods to make it work. This is the expected output using students1.in and seating 1 .in: 5. moveStudentFromChairs ToLine This method simulates a student being eliminated during the musical chairs game. - This method randomly chooses a student to be eliminated from musicalChairs. - Use StdRandom.uniform ( x ) , where x is the number of students currently in musicalChairs, to get a number n between 0 (inclusive) and x (exclusive). - Remove the student at position n from musicalChairs. Position 0 is the first student. - Notice that the driver is setting a seed for the random number generator. The seed value is 2022. - Once the student is removed from the chairs call insertByHeight to insert the student into studentsInLine. - Watch this video for more information. Note: this method depends on insertMusicalChairs and insertByHeight. Students in Musical Chairs: M. Brow N. Dyer P. Ferg D. Harb M. Hawk C. Heat J. Keer G. Mata C. McLa D. Mont P. Reis W. Ryde N. Schn S. Sink F. Wolf - POINTS TO FRONT 6.
  • 13. insertByHeight Each student that is eliminated from the musical chairs game is put back in the line (studentsinLine linked list) by height order. - The eliminated student is given as as parameter - Iterate through studentsinLine searching for a student that is taller than the eliminated student. You will have 3 cases: - eliminated student is the shortest, insert at the front of the list. - eliminated student is the tallest, insert at the end of the list. - eliminated student is not the shortest or tallest, insert in the middle of the list. - When inserting into the list, a student will be insert AFTER all students of the same height. - Watch this video for more information. - This method is called from moveStudentFromChairs ToLine() to insert a student that was eliminated from the musical chairs game. In the driver, you can test this method independently using moveStudentFromChairsToLine. 7. eliminateLosingStudents This method eliminates all students from musicalChairs except the winner. 1. Obtain the number of students currently in the musicalChairs, call it size. 2. Repeatedly call moveRandom StudentFromChairs ToLine with the size until one player is left. 3. Don't forget to update size after each call as the number of students in the chairs decreases by 1. At the end of this method one student will remain in musicalChairs, this is the winner! The winner doesn't leave the musical chairs to enter the line. All other students will be standing on the line in ascending order by height. NOTE: this method depends on all previous methods. 8. seatMusicalChairsWinner This method will seat the winner of the musical chairs game! After the game of playMusicalChairs, you must seat the winner first! - If musical musicalChairs contains only one node (that is, the winner), delete the node. The list will be empty. - Insert the student object into the first empty spot in the classroom (seatingStudents). Implementation Notes - YOU MAY only update the methods with the WRITE YOUR CODE HERE line. - DO NOT add any instance variables to the Classroom class. - DO NOT add any public methods to the Classroom class. - YOU MAY add private methods to the Classroom class. - DO NOT use System exit()