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
James River Jewelry is a small jewelry shop. While James River Jewelry does sell typical jewelry purchased form jewelry vendors,
Sveta_85 [38]

Answer:

This question is comprising many parts (a to r). That is impossible to answer in one sheet. Following are attached images having answers to most of the parts.

I hope it will help you a lot.

Explanation:

7 0
3 years ago
What is the difference between filler and electrode in Welding? Can a filler be an electrode? Can an electrode be a filler? Why?
Vlada [557]

Explanation:

<u>Filler:</u>

  Filler is the material rod is used when we are joining two material by using welding process.If thickness of work piece is more so it will become compulsory to provide some filler material for making the welding join to withstand high stresses.

<u>Electrode:</u>

  Electrode is the element which is used to complete the electric circuit in welding .Some time electrode is connected with positive terminal and some time with negative terminal ,it depends on the requirement of welding process.In Tungsten inert gas welding electrode is connected negative terminal but on the other hand Metal inert gas welding electrode is connected with positive terminal.Electrode can be consumable non-consumable depends on the condition.

Yes electrode can be work as filler material ,in Metal inert gas welding wire is used as electrode as well as filler material.In Metal inert gas welding consumable electrode is used on the other hand Tungsten inert gas welding non-consumable electrode is used.In Tungsten inert gas welding if thickness of work pieces is less than 5 mm then no need to used any filler material but if thickness is more than 5 mm then we have to use filler material.

8 0
3 years ago
After testing a model of a fuel-efficient vehicle, scientists build a full-sized vehicle with improved fuel efficiency. Which st
Mazyrski [523]
B evaluate the solution. Sorry if I'm wrong.
4 0
3 years ago
Select four examples of fluid or pneumatic power systems.
Dennis_Churaev [7]

Answer:

Students learn about the fundamental concepts important to fluid power, which includes both pneumatic (gas) and hydraulic (liquid) systems. Both systems contain four basic components: reservoir/receiver, pump/compressor, valve, cylinder.

Explanation:

8 0
3 years ago
Read 2 more answers
Select the best answer for the question.
dalvyx [7]
I think the Acid level
5 0
3 years ago
Other questions:
  • What is the entropy of a closed system in which 25 distinguishable grains of sand are distributed among 1000 distinguishable equ
    5·2 answers
  • Analyze the following ideal transistor circuit. Can use general rule of thumbs for analyzing transistors b-base, c- collector, a
    9·2 answers
  • A 1000 KVA three phase transformer has a secondary voltage of 208/120. What is the secondary full load amperage?
    9·1 answer
  • As shown, a load of mass 10 kg is situated on a piston of diameter D1 = 140 mm. The piston rides on a reservoir of oil of depth
    9·1 answer
  • What is a beam on a bridge? what does it do?
    6·1 answer
  • Thermodynamics fill in the blanks The swimming pool at the local YMCA holds roughly 749511.5 L (749511.5 kg) of water and is kep
    6·1 answer
  • HELP _7. All of the following except which would lead to an INCREASE in friction?
    15·1 answer
  • 10. True or False? A disruptive technology<br> radically changes the way people live and<br> work.
    5·2 answers
  • A hammer can be used to see how a mineral breaks. If you observe square chunks of the mineral when broken, what can you conclude
    15·1 answer
  • Technician A says that the definition of torque is how far the crankshaft twists in degrees.Technician B says that torque can re
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!