Answered step by step
Verified Expert Solution
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 twodimensional 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
@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 removeAbsentStudentsint 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 twodimensional 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 and filling the array column by
column. Empty seats in the seating chart are represented by nul
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 SeatingChartroster
Complete the SeatingChart constructor below.
public SeatingChartArrayList 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 has executed, the
array seats would contain the following values and the method would
return the value
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 SeatingChartArrayList 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.
Step 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