/** * *********************** Provided class - do not modify. *********************** * This class represents a student. Each student has a name and a problem difficulty. * Note: Student objects are...

1 answer below »
/** * *********************** Provided class - do not modify. ************************ This class represents a student. Each student has a name and a problem difficulty.* Note: Student objects are immutable - that is, there are no mutator methods in this* class by design.*/public class Student {// instance variablesprivate String name;private String problemDifficulty;//class constantprivate static final String[] DIFFICULTY_CODE = {"very easy", "easy", "medium", "difficult", "very difficult"};/*** Constructor for objects of class Student - all Student* objects must have a name and a problem difficulty.*/public Student(String name, String problemDifficulty) {XXXXXXXXXXthis.name = name;XXXXXXXXXXif (contains(DIFFICULTY_CODE, problemDifficulty)) {XXXXXXXXXXthis.problemDifficulty = problemDifficulty;}else {XXXXXXXXXXthis.problemDifficulty = "medium";XXXXXXXXXXSystem.out.println("Invalid problem difficulty for student: " + name + ". Defaulting to \"medium\".");}}/*** accessor method for Student's name.*/public String getName() {XXXXXXXXXXreturn name;}/*** accessor method for Student's problem difficulty.*/public String getDifficulty() {XXXXXXXXXXreturn problemDifficulty;}/*** toString - returns the String representation of a Student object.*/public String toString() {XXXXXXXXXXreturn "{ Student's name: " + name + ", Problem difficulty: " + problemDifficulty + " }";}/*** private class method contains - helps validate the problem difficulty code* in the constructor.*/private static boolean contains(String[] array, String target) {XXXXXXXXXXfor (int i = 0; i < array.length; i++) {XXXXXXXXXXif (array[i].toLowerCase().equals(target.toLowerCase())) return true;}XXXXXXXXXXreturn false;}}

Part 1: (No template provided) Write a class calledLineAtOfficeHour to represent a line of students waiting
to speak with their teacher during an oce hour. The teacherobserves a \ rst-come- rst-serve" policy, and the
most students that can t in a line in the teacher's oce is 10. Forthis exercise, you will need to work with
the provided Student class containing various constructors andmethods (do not modify this class) - so make
sure you read and understand how to use the Student class beforetackling this assignment.
Your class should have the following variables, constructors andmethods:
instance variables:
- an array of Students called line,
- an integer N representing the number of students in theline,
- an integer back representing the index of the last student inline;

- a no-argument constructor which sets the length of the line to10, however the line should start o
- a constructor that takes an array of Student objects as argumentand lls the line variable with up
to 10 Students. If the given argument array has more than 10Students, then you should populate
the line with 10 random Students out of the given array;

a method called isEmpty which returns true if theline is empty;
a method called isFull which returns true if theline is full;
a method called size which returns the number ofstudents waiting in line;
a method called enterLine which takes a Studentobject as argument and puts it at the back of the line
(i.e. behind the last student currently in line). This method doesnot need to return anything. Note: if
the line is full, the Student should not be placed in the line andshould be rejected with an appropriate
a method called seeTeacher which removes theStudent object from the front of the line (i.e. the student
who is currently rst in line gets to see the teacher when thismethod is called) and returns the Student
object. Note: the remaining students should move toward the frontof the line as result of this method
being called;
a method called whosNext which returns the name ofthe Student object at the front of the line, however
it does NOT remove it from the line;
a method called studentsInLine which returns a 2-Darray such that the rst column contains the names
of the students that are standing in line and the second columncontains their respective problem diculty
code (see the Student class for more detail).

Answered 1 days AfterMay 12, 2022

Answer To : /** * *********************** Provided class - do not modify. *********************** * This class...

Vibhav answered on May 14 2022
9 Votes

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here