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
What is the chord length of an airplane called?
aliya0001 [1]

Answer:

The distance from the leading edge to the trailing edge is called the chord, denoted by the symbol c. The ends of the wing are called the wing tips, and the distance from one wing tip to the other is called the span, given the symbol s

3 0
3 years ago
Consider a turbojet powered airplane flying at a standard altitude of 30,000ft at a velocity of 500 mph. The turbojet engine its
grandymaker [24]

Answer:

T  = 20.42 N

Explanation:

given data

standard altitude = 30,000 ft

velocity Ca = 500 mph = 0.4 m/s

inlet areas Aa = 7 ft² = 0.65 m²

exit areas Aj = 4.5 ft²  =  0.42 m²

velocity at exit Cj = 1600 ft/s = 487.68 m/s

pressure exit \rhoj = 640 lb/ft²   = 0.3 bar

solution

we get here thrust of the turbojet that is  express as

thrust of the turbojet T = Mg × Cj - Ma × Ca + ( \rhoj Aj - \rhoa Ag )   .............1

here Ma = Mg

Ma = \rhoa × Ca Aa = 0.042 kg/s

put value in equation 1 we get

T = 0.042 × (487.68 -0.14) + ( 0.3 ×  - 0.3 × 0.65 )  

T  = 20.42 N

5 0
3 years ago
Could a volcanic eruption suddenly bury a city and its inhabitants? (Plz explain to me)
andrezito [222]
Yes a volcanic eruption can suddenly bury a city ! if you look up some stuff on pompeii you can learn more
7 0
3 years ago
Draw a circuit diagram of one lamp controlled by one switch and show how insulation resistance test is carried out​
Ganezh [65]

isisksksksjjsjsjsjjsjd

8 0
3 years ago
I need answer to this question
blagie [28]

Answer:

1. Graph C

2. Friction

Explanation:

1. The line on all of the graphs shown represents velocity. The formula for velocity is v=\frac{d}{t} where d is distance and t is time. Focusing on the first lap, the starting point on the graph should be the origin and the "ending" point should be (20, 3). These requirements eliminate graph A as an answer because its "end" is not (20, 3). During the break, the student does not move, so the slope of the line should be completely horizontal. The break lasted for 5 minutes, so the correct graph should have a horizontal line between the points (20, 3) and (25, 3). This requirement eliminates graph B and D because their break is either not long enough (B) or too long (D).

2. Friction slows down the movement of objects. When an object is rough, it produces more friction which causes the object to be slowed more. When an object is smooth, friction slows it less than it would for a rough object.

6 0
3 years ago
Other questions:
  • A 50 kVA, 2400/240 V, 1-Φ transformer is connected to act as a booster from 2400 to 2640 V. Without exceeding the rated current
    5·1 answer
  • The cylindrical aluminum air tank below is to be rated for 300 psi and it must comply with the ASME Boiler Code which requires a
    5·2 answers
  • Hydrogen gas (density = 1.165 kg/m^3 ) is stored at 25°C in a permeable cylindrical container which has an outer diameter of 0.2
    11·1 answer
  • Assume there exists some hypothetical metal that exhibits ferromagnetic behavior and that has (1) a simple cubic crystal structu
    6·1 answer
  • How is varnished timber shaped and cut?
    11·1 answer
  • While discussing diagnostic procedures: Technician A says that after the visual inspection has been performed, the DTCs should b
    14·1 answer
  • HELP PLS Leaders usually start as
    14·1 answer
  • Which of the following is an interdisciplinary approach to architectural or interior design most like?
    11·2 answers
  • A flow of 2.6 MGD leaves a primary clarifier with a BOD of 131 mg/L. Determine the aeration period (hydraulic detention time) of
    15·1 answer
  • Where can you find the grade for a piece of property?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!