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
Consider casting a concrete driveway 40 feet long, 12 feet wide and 6 in. thick. The proportions of the mix by weight are given
Akimi4 [234]

Answer:

Weight of cement = 10968 lb

Weight of sand = 18105.9 lb

Weight of gravel = 28203.55 lb

Weight of water = 5484 lb

Explanation:

Given:

Entrained air = 7.5%

Length, L = 40 ft

Width,w = 12 ft

thickness,b= 6 inch, convert to ft = 6/12 = 0.5 ft

Specific gravity of sand = 2.60

Specific gravity of gravel = 2.70

The volume will be:

40 * 12 * 0.5 = 240 ft³

We need to find the dry volume of concrete.

Dry volume = wet volume * 1.54 (concrete)

Dry volume will be = 240 * 1.54 = 360ft³

Due to the 7% entarained air content, the required volume will be:

V = 360 * (1 - 0.07)

V = 334.8 ft³

At a ratio of 1:2:3 for cement, sand, and gravel respectively, we have:

Total of ratio = 1+2+3 = 6

Their respective volume will be =

Volume of cement = \frac{1}{6}*334.8 = 55.8 ft^3

Volume of sand = \frac{2}{6}*334.8 = 111.6 ft^3

Volume of gravel = \frac{3}{6}*334.8 = 167.4 ft^3

To find the pounds needed the driveway, we have:

Weight = volume *specific gravity * density of water

Specific gravity of cement = 3.15

Weight of cement =

55.8 * 3.15 * 62.4 = 10968 pounds

Weight of sand =

111.6 * 2.60 * 62.4 = 18105.9 lb

Weight of gravel =

167.4 * 2.7 * 62.4 = 28203.55 lb

Given water to cement ratio of 0.50

Weight of water = 0.5 of weight of cement

= 1/2 * 10968 = 5484 lb

4 0
3 years ago
Which term defines the amount of mechanical work an engine can do per unit of heat energy it uses?
skad [1K]

Answer:

d

Explanation:

is the because that's the amount of work in making machine can do producing heat

7 0
3 years ago
Most deformation occurs along plate boundaries because ________.
Svetlanka [38]
B) the plates are in constant motion and as a result the boundaries are where they interact
3 0
3 years ago
what is called periodic function give example? Plot the output which is started with zero degree for one coil rotating in the un
marta [7]

Answer:

A periodic function is a function that returns to its value over a certain period at regular intervals an example is the wave form of flux density (B) = sin <em>wt</em>

Explanation:

A periodic function is a function that returns to its value over a certain period at regular intervals an example is the wave form of flux density (B) = sin <em>wt</em>

attached to the answer is a free plot of the output starting with zero degree for one coil rotating in a uniform magnetic field

B ( wave flux density ) = Bm sin<em>wt  and w = </em>2\pif = \frac{2\pi }{T} rad/sec

3 0
3 years ago
A particle moves along a straight line with a velocity V=(200s) mm/s, where s is in millimeters. Determine acceleration of the p
iragen [17]

Answer:

200 mm/s²

Explanation:

See it in the pic

8 0
3 years ago
Other questions:
  • 1. Why is outside air mixed with return air?​
    6·1 answer
  • What does this map show about the Viking civilization?
    7·2 answers
  • Explain how use of EGR is effective in reducing NOx emissions 4. In most locations throughout the U.S., the octane number of reg
    5·1 answer
  • How many volts does one cell produce?
    14·2 answers
  • Compute the estimated actual endurance limit for SAE 4130 WQT 1300 steel bar with a rectangular cross section of 20.0 mm by 60 m
    11·1 answer
  • WHO EVER COMMENTS FIRST GETS BRAINLIEST LOL
    15·2 answers
  • An air conditioning system operating on reversed carnot cycle is required to remove heat from the house at a rate of 32kj/s to m
    5·1 answer
  • -0-1"<br> -0<br> -20<br> -15<br> -10<br> 0<br> -5
    9·1 answer
  • Select the correct answer. Felix aspires to be an engineer working for the government. What credentials will Felix require to ap
    5·1 answer
  • Multiple Choice
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!