1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
xz_007 [3.2K]
4 years ago
8

You will create three classes, the first two being Student and LineAtOfficeHour. The instances of the first class defines a sing

le student while an instance of the second class defines a line of students waiting to see an instructor in their office hour. The Student class should have the following: • Private instance variables to store the first and last name of the student. • A constructor that sets all of the instance variables. You do not need to write a no-arg constructor in addition to the constructor that sets all of the instance variables. • Public methods to get and set the instance variables and a method fullName() that returns the full name of the student (first then last) as a String (i.e., does not print it out to the screen). The LineAtOfficeHour class holds Student objects in a line and has methods to manipulate this line. • Private instance variables: o an array of Students called line. o an integer N representing the number of students in the line. o an integer back representing the index of the last student in line. • Constructors: o no-argument constructor which sets the length of the line to 5, however the line should start off empty. • a constructor that takes an array of Student objects as argument and fills the line variable with up to 5 Students (but can also take as input an array of fewer than 5 Student objects). If the given input argument array has more than 5 Students, then you should populate the line with the first 5 Students out of the input array. • Public methods: • a method called isEmpty which returns true if the line is empty. o a method called isFull which returns true if the line is full. o a method called size which returns the number of students waiting in line. o a method called enterLine which takes a Student object as the argument and puts it at the back of the line (i.e. behind the last student currently in line). This method does not need to return anything. Note: if the line is full, the Student should not be placed in the line and should be rejected with an appropriate message. o a method called see Teacher which removes the Student object from the front of the line (i.e. the student who is currently first in line gets to see the teacher when this method is called) and returns the Student object. Note: the remaining students should move toward the front of the line as result of this method being called. o a method called whoslnLine which returns a list (as a String) of all the names of the Students in the line, in the order they are in line (the first student first, a comma, the second name, and so on). Finally, write a driver class TestLine that will create a LineAtOfficeHour object, fill it with Student objects, and test that the methods of LineAtOfficeHour function correctly.
Engineering
1 answer:
White raven [17]4 years ago
6 0

Answer:

Complete solution is given below:

Explanation:

//student class

class Student{

  private String firstname,lastname;

 

  //constructor

  Student(String first,String last){

      this.firstname=first;

      this.lastname=last;

  }

 

  //getters and setters

  public String getFirstname() {

      return firstname;

  }

  public void setFirstname(String firstname) {

      this.firstname = firstname;

  }

  public String getLastname() {

      return lastname;

  }

  public void setLastname(String lastname) {

      this.lastname = lastname;

  }

  //function to get the fullname of student

  public String fullName() {

      return this.firstname+" "+this.lastname;

  }

}

//class for line at office hour

class LineAtOfficeHour{

 

  private Student line[];

  private int N=0;

  private int back=0;

 

  //empty constructor

  LineAtOfficeHour() {

      line=new Student[5];

  }

  //parameterized constructor

  LineAtOfficeHour(Student st[]) {

      int i=0;

      line=new Student[5];

      while(i<st.length && i<5) {

          line[i]=st[i];

          i++;

      }

      this.N=i;

      this.back=i-1;

  }

  //function to check if line is empty or not

  public boolean isEmpty() {

      if(this.N==0)

          return true;

      else

          return false;

  }

  //function to check if line is full

  public boolean isFull() {

      if(this.N==5) {

          return true;

      }else

          return false;

  }

  ///function to get the size of line

  public int size() {

      return this.N;

  }

 

  //function to add a student to the line

  public void enterLine(Student s) {

      if(isFull())

          System.out.println("Line is full!!!!");

      else {

          line[++back]=s;

          this.N++;

      }

  }

  public Student seeTeacher() {

      Student result=null;

      if(this.N>=0) {

          result=line[0];

          int i=0;

          for(i=1;i<N;i++) {

              line[i-1]=line[i];

          }

          line[i-1]=null;

          this.N--;

          this.back--;

      }

     

     

      return result;

  }

  //function to print students in line

  public String whosInLine() {

      String result ="";

      for(int i=0;i<this.N;i++) {

          result+=line[i].fullName()+",";

      }

      return result;

  }

}

//driver method

public class TestLine {

  public static void main(String[] args) {

      LineAtOfficeHour list=new LineAtOfficeHour();

     

      if(list.isEmpty()) {

          System.out.println("Line is empty!!!!!!!!!");

      }

     

      Student s1[]=new Student[3];

      s1[0]=new Student("John","Smith");

      s1[1]=new Student("Sam","Zung");

      s1[2]=new Student("Peter","Louis");

      list=new LineAtOfficeHour(s1);

     

      if(list.isEmpty()) {

          System.out.println("Line is empty!!!!!!!!!");

      }else {

          System.out.println("Line is not empty.........");

      }

     

      System.out.println("Students in line: "+list.whosInLine());

     

      System.out.println("Student removed: "+list.seeTeacher().fullName());

     

      System.out.println("Students in line: "+list.whosInLine());

  }

}

You might be interested in
Entropy change is evaluated using Eq. 6.2a based on an internally reversible process. Can the entropy change between two states
Vadim26 [7]

Answer:

YES

Explanation:

Entropy is an extensive property of the system entropy change that value of entropy change can be determined for any process between the states whether reversible or not. i have attached the formula to calculate entropy change which is independent of whether the system is reversible or not and can be determined for any process.

4 0
3 years ago
-1 1/6 divided by 2 1/3
pantera1 [17]

Answer:

-\frac{1}{2}

Explanation:

-1\frac{1}{6}:2\frac{1}{3}=\\  \\=-\frac{7}{6}:\frac{7}{3}\\  \\=-\frac{7}{6}*\frac{3}{7}\\  \\=-\frac{1}{2}

4 0
3 years ago
A sample of municipal sewage is diluted to 1% by volume prior to running a BOD5 analysis. After 5 days the oxygen consumption is
liberstina [14]

Answer:

BOD5 = 200 mg/L

Explanation:

given data

diluted = 1% = 0.01

time = 5 day

oxygen consumption = 2.00 mg · L−1

solution

we get here BOD5  that is BOD after 5 day

and here total volume is 100% = 1

so dilution factor is \frac{100}{1}    =  100

so BOD5 is

BOD5 = oxygen consumption × dilution factor

BOD5 = 2 × 100

BOD5 = 200 mg/L

4 0
3 years ago
Can anyone explain how a Halbek Device works
dedylja [7]

Answer:

The Halbek Device can be used effectively on some weapons with practice and certain loadouts. ... This tends to help high-damage weapons or weapons with high multipliers

8 0
2 years ago
Read 2 more answers
A 5-cm-diameter shaft rotates at 4500 rpm in a 15-cmlong, 8-cm-outer-diameter cast iron bearing (k = 70 W/m·K) with a uniform cl
-BARSIC- [3]

Answer:

(a) the rate of heat transfer to the coolant is Q = 139.71W

(b) the surface temperature of the shaft T = 40.97°C

(c) the mechanical power wasted by the viscous dissipation in oil 22.2kW

Explanation:

See explanation in the attached files

5 0
3 years ago
Other questions:
  • I dont undertand this coding problem (Java):
    8·1 answer
  • A six-lane freeway (three lanes in each direction) currently operates at maximum LOS C conditions. The lanes are 11 ft wide, the
    5·1 answer
  • Refers to the capability to keep moving forward on a specified grade.
    5·1 answer
  • g A pump is required to deliver 100 gpm at a head of 100 ft, but the pump rated capacity is 150 gpm at a head of 100 ft. If the
    9·1 answer
  • A steel rectangular tube has outside dimensions of 150 mm x 50 mm and a wall thickness of 4 mm. State the inside dimensions, the
    5·1 answer
  • Someone has suggested that the air-standard Otto cycle is more accurate if the two polytropic processes are replaced with isentr
    10·1 answer
  • The specific gravity of a fluid with a weight density of 31.2 lb/ft is a. 2.00 b. 0.969 c. 0.500 d. 1.03
    10·1 answer
  • Fill in the blank to correctly complete the statement below.
    6·1 answer
  • The point of contact of two pitch circles of mating gears is called?
    10·1 answer
  • Imagine waking up every day and no one is home besides your dog and you how would you feel?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!