Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello, I need help on the following four methods: moveStudentsFromChairsToLine, insertByHeight, eliminateLosingStudents, and seatMusicalChairsWinner. The instructions and implementation directions are below. Thank you!! Overview In
Hello, I need help on the following four methods: moveStudentsFromChairsToLine, insertByHeight, eliminateLosingStudents, and seatMusicalChairsWinner. The instructions and implementation directions are below. Thank you!!
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 2D array simulates students at their seats A Circular Linked List simulates students M OIIIyly Linkeu List mIIlulates stuueIII 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. Classroom.java - 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: - studentinLine 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 2D boolean array that shows which seats exist for students to seat at. - studentsSitting 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 studentsSitting[i][j] - 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. 5. moveStudentFromChairsToLine 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. 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 moveStudentFromChairsToLine() 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 moveRandomStudentFromChairsToLine 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 winnerl 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). Students in Line: P. Ferg G. Mata S. Sink M. Brow N. Schn M. Ryde N. Dyer F. Wolf C. McLa M. Hawk P. Reis C. Heat D. Mont D. Harb M. Modi Sitting Students: J. Keer EAPTY EAPTY EMPTY EYPTY EMPTY ERPTY xxxEMPTYxEMPTYxEMPTYxxxEMPTYEMPTYEMPTYEMPTYEMPTYxxxEMPTYEPPTYERPTYERPTYENPTYxxxEMPTY Students in Musical Chairs: EMPTYStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started