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
Anyone know sebastian from bb
faust18 [17]

Answer:

No

Explanation:

Not rlly sure

4 0
4 years ago
Waste that is generated by a business is called a _____________.
Vinil7 [7]

Answer:

A waste stream

Explanation:

7 0
3 years ago
Read 2 more answers
The design for a new cementless hip implant is to be studied using an instrumented implant and a fixed simulated femur.
OlgaM077 [116]

Answer:

a) the velocity of the implant immediately after impact is 20 m/s

b) the average resistance of the implant is 40000 N

Explanation:

a) The impulse momentum is:

mv1 + ∑Imp(1---->2) = mv2

According the exercise:

v1=0

∑Imp(1---->2) = F(t2-t1)

m=0.2 kg

Replacing:

0+F(t_{2} -t_{1} )=0.2v_{2}

if F=2 kN and t2-t1=2x10^-3 s. Replacing

0+2x10^{-3} (2x10^{-3} )=0.2v_{2} \\v_{2} =\frac{4}{0.2} =20m/s

b) Work and energy in the system is:

T2 - U(2----->3) = T3

where T2 and T3 are the kinetic energy and U(2----->3) is the work.

T_{2} =\frac{1}{2} mv_{2}^{2}  \\T_{3} =0\\U_{2---3} =-F_{res} x

Replacing:

\frac{1}{2} *0.2*20^{2} -F_{res} *0.001=0\\F_{res} =40000N

3 0
3 years ago
In , the industries with the most complaints to the Better Business Bureau were banks, cable and satellite television companies,
navik [9.2K]

Answer:

Answer for the question:

In , the industries with the most complaints to the Better Business Bureau were banks, cable and satellite television companies, collection agencies, cellular phone providers, and new car dealerships (USA Today, April 16, 2012). The results for a sample of complaints are contained in the DATAfile named BBB. Click on the datafile logo to reference the data."

is explained in the attachment.

Explanation:

Download pdf
6 0
3 years ago
Technician A says that 5W-30 would be better to use than 20W-50 in most vehicles in
shtirl [24]
Technician is correct sorry if im wronghg
5 0
3 years ago
Read 2 more answers
Other questions:
  • The screw of shaft straightener exerts a load of 30 as shown in Figure . The screw is square threaded of outside diameter 75 mm
    5·1 answer
  • One kilogram of water contained in a piston–cylinder assembly, initially saturated vapor at 460 kPa, is condensed at constant pr
    15·1 answer
  • 1. A farmer had 752 sheep and took one shot that got them all. How did he do it?
    9·1 answer
  • In a typical transmission line, the current I is very small and the voltage V is very large. A unit length of the line has resis
    8·1 answer
  • Crest is to high, as through is to
    12·2 answers
  • A plane wall, 7.5 cm thick, generates heat internally at the rate of 105W/m3. One side of the wall is insulated and the other si
    14·1 answer
  • Plz give solutions..... ​
    6·1 answer
  • A(94,0,14) B(52,56,94) C(10,6,48) D(128,64,10)
    6·1 answer
  • ¿Cuál es el objetivo de la participación del gobierno en la economía?
    6·1 answer
  • Mang Tisoy bought two bags of onion from the market. One bag weighed 8 kg
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!