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]
3 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]3 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
Biblical studies of john​
nevsk [136]

Answer:

<h2>the answer of sols brother is correct</h2><h3>hope it helps you have a good day</h3><h2 />

5 0
3 years ago
A shunt regulator utilizing a zener diode with an incremental resistance of 8 ohm is fed through an 82-Ohm resistor. If the raw
spayn [35]

Answer:

\triangle V_0=0.08V

Explanation:

From the question we are told that:

Incremental resistance  R=8ohms

Resistor Feed R_f=82ohms

Supply Change \triangle V=1

Generally the equation for  voltage rate of change is mathematically given by

 \frac{dV_0}{dV}=\frca{R}{R_1r_3}

Therefore

 \triangle V_0=\triangle V*\frac{R}{R_fR}

 \triangle V_0=1*\frac{8}{8*82}

 \triangle V_0=0.08V

7 0
3 years ago
A home electrical system is joined to the electric company's system at the junction of the
aleksandrvk [35]

That would be B, I hope this helps!

5 0
2 years ago
1.Which thematic group uses technology to direct the behavior of dynamical systems, ensuring that they behave in a predictable m
dsp73

The thematic group governing the behavior of dynamic system is control system, and the one packaging the miniature components to conduct electricity is electronic system. Thus, option E is correct.

<h3>What are thematic groups?</h3>

The thematic groups comprises of group of people that work over the same idea or the concept. The thematic groups working on different projects and ideas comprised to work with different systems.

The control of dynamic system in order to produce the desirable outcome has been the role of the control system.

The packaging of the electronic miniatures in system that performs the role of direction of electricity is the role of electronic system thematic group. Thus, option E is correct.

Learn more about thematic group, here:

brainly.com/question/32731

#SPJ1

8 0
2 years ago
Cho P1= XdaN, P2=3.X daN, P= 2.X (daN). a=1m, b=2m,MCN hình tròn d= (100+X)mm1/ Tính nội lực tại các mặt cắt cách ngàm 0,5m; 1m;
DaniilM [7]

Answer:

Please explain it in English so that i can help or you need someone else who can speak Vietnam

5 0
2 years ago
Other questions:
  • A circuit-switching scenario in whichNcs users, each requiring a bandwidth of 25 Mbps, must share a link of capacity 150 Mbps.
    12·1 answer
  • A copper wire of original diameter .80 m exhibits a maximum tensile load/ strength at an engineering stress= 248.2 mpa. its duct
    11·1 answer
  • The Manufacturing sector is the only sector where Lean manufacturing philosophy can be applied. a)- True b)- False
    12·1 answer
  • Choose the best data type for each of the following so that any reasonable value is accommodated but no memory storage is wasted
    5·1 answer
  • Select four types of engineers who might be involved in the development of a product such as an iPhone.
    6·2 answers
  • Do all websites use the same coding to create?
    8·1 answer
  • What is the function rule for the line? f(x)=−32x−2f(x)=−23x−2f(x)=32x−2f(x)=−32x+2A coordinate grid with x and y axis ranging f
    6·1 answer
  • A driver complains that his front tires are wearing
    14·1 answer
  • The use of seatbelts in a car has significantly reduced the number of crash fatalities. Which statement best explains how societ
    11·1 answer
  • How do we infer that there is
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!