Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITTEN IN IAVA: Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Unless otherwise noted in the question, assume

WRITTEN IN IAVA:
Assume that the classes listed in the Java Quick Reference have been imported where
appropriate.
Unless otherwise noted in the question, assume that parameters in method calls are The class Seatingchart, shown below, uses a two-dimensional array to
represent the seating arrangement of students in a classroom. The seats in the
classroom are in a rectangular arrangement of rows and columns.
/** Removes students who have more than a given number of
absences from the seating chart, replacing those entries
in the seating chart with null and returns the number of
students removed.
@param allowedAbsences an integer >=0
@return number of students removed from seats
Postcondition:
All students with allowedAbsences or fewer are in their
original positions in seats.
No student in seats has more than allowedAbsences
absences.
*/- Entries without students contain null.
public int removeAbsentStudents(int allowedAbsences)
{/* to be implemented in part (b)*/}
// There may be instance variables, constructors, and methods
// that are not shown.
} a) Write the constructor for the Seatingchart class. The constructor
initializes the seats instance variable to a two-dimensional array with the
given number of rows and columns. The students in student List are
copied into the seating chart in the order in which they appear in
studentList. The students are assigned to consecutive locations in the
array seats, starting at seats [0][0] and filling the array column by
column. Empty seats in the seating chart are represented by nul1.
For example, suppose a variable ArrayList roster contains references
to student objects in the following order.
A SeatingChart object would have seats initialized with the following
values with the call new SeatingChart(roster,3,4).
Complete the SeatingChart constructor below.
public SeatingChart(ArrayList b) Write the removeAbsentStudents method, which removes students who
have more than a given number of absences from the seating chart and
returns the number of students that were removed. When a student is
removed from the seating chart, a null is placed in the entry for that
student in the array seats. For example, suppose the SeatingChart
variable introcs has been created such that the array seats contains the
following entries showing both students and their number of absences.
After the call introcs. removeAbsentStudents (4) has executed, the
array seats would contain the following values and the method would
return the value 3.
Class information repeated from the beginning of the question:
public class Student
public String getName()
public int getAbsenceCount()
public class seatingChart
private Student[][] seats
public SeatingChart(ArrayList not
null and that methods are called only when their preconditions are satisfied.
In writing solutions for each question, you may use any of the accessible methods that
are listed in classes defined in that question. Writing significant amounts of code that
can be replaced by a call to one of these methods will not receive full credit.
A student in a school is represented by the following class.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions