Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

I need help with the following method in java! Implementation Overview of files provided Student class which holds a students information. SNode class represents the

I need help with the following method in java!

Implementation

Overview of files provided

Student class which holds a students 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.

StdIn 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.

studentInLine which refers to the first student in the singly linked list.

1. enterClassroom

This method simulates students standing in line and coming into the classroom (not leaving the line).

You have been provided some input files to test this method (students1.in, students2.in, students3.in, students4.in). The format is as follows:

One line containing an integer representing the number of students in the file (one per line)

Several lines (one for student) containing students first name, last name, and height, space separated

Use the StdIn 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.readString() read the next String value from the opened file

To read one student do: String firstName = StdIn.readString(); String lastName = StdIn.readString(); int height = StdIn.readInt();

This method creates students listed on the input file and inserts students to the front of the singularly linked list studentsInLine.

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 students1.in

additional instructions:

/**

* 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions