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
A PMMA plate with a 25 mm (width) x 6.5 mm (thickness) cross-section has a contained crack of length 2c = 0.5 mm in the center o
victus00 [196]

Answer:

LAOD = 6669.86 N

Explanation:

Given data:

width= 25 mm = 25\times 10^{-3} m

thickness = 6.5 mm = 6.5\times 10^{-3} m

crack length 2c = 0.5 mm at centre of specimen

\sigma _{applied} =  1000 N/cross sectional area

stress intensity factor  =  k  will be

\sigma_{applied} = \frac{1000}{25\times 10^{-3}\times 6.5\times 10^{-3}}

                   = 6.154\times 10^{6} Pa

we know that

k =\sigma_{applied} (\sqrt{\pi C})

  =6.154\sqrt{\pi (2.5\times 10^{-04})}          [c =0.5/2 = 2.5*10^{-4}]

K = 0.1724 Mpa m^{1/2} for 1000 load

ifK_C = 1.15 Mpa m^{1/2} then load will be

Kc = \sigma _{frac}(\sqrt{\pi C})

1.15 MPa = \sigma _{frac}\times \sqrt{\pi (2.5\times 10^{-04})}

\sigma _{frac} = 41.04 MPa

load = \sigma _{frac}\times Area

load = 41.04 \times 10^6 \times 25\times 10^{-3}\times 6.5\times 10^{-3} N

LAOD = 6669.86 N

3 0
2 years ago
- Viscoelastic stress relaxation
My name is Ann [436]

Explanation:

The correct answers to the fill in the blanks would be;

1. Viscoelastic stress relaxation refers to scenarios for which the stress applied to a polymer must decay over time in order to maintain a constant strain. Otherwise, over time, the polymer chains will slip and slide past one another in response to a constant applied load and the strain will increase (in magnitude).

2. Viscoelastic creep refers to scenarios for which a polymer will permanently flow over time in response a constant applied stress.

The polymer whose properties have been mentioned above is commonly known as Kevlar.

It is mostly used in high-strength fabrics and its properties are because of several hydrogen bonds between polymer molecules.

5 0
3 years ago
Four kilograms of carbon monoxide (CO) is contained in a rigid tank with a volume of 1 m3. The tank is fitted with a paddle whee
Juli2301 [7.4K]

Answer:

a) 1 m^3/Kg  

b) 504 kJ

c) 514 kJ

Explanation:

<u>Given  </u>

-The mass of C_o2 = 1 kg  

-The volume of the tank V_tank = 1 m^3  

-The added energy E = 14 W  

-The time of adding energy t = 10 s  

-The increase in specific internal energy Δu = +10 kJ/kg  

-The change in kinetic energy ΔKE = 0 and The change in potential energy  

ΔPE =0  

<u>Required  </u>

(a)Specific volume at the final state v_2

(b)The energy transferred by the work W in kJ.  

(c)The energy transferred by the heat transfer W in kJ and the direction of  

the heat transfer.  

Assumption  

-Quasi-equilibrium process.  

<u>Solution</u>  

(a) The volume and the mass doesn't change then, the specific volume is constant.

 v= V_tank/m ---> 1/1= 1 m^3/Kg  

(b) The added work is defined by.  

W =E * t --->  14 x 10 x 3600 x 10^-3 = 504 kJ  

(c) From the first law of thermodynamics.  

Q - W = m * Δu

Q = (m * Δu) + W--> (1 x 10) + 504 = 514 kJ

The heat have (+) sign the n it is added to the system.

7 0
3 years ago
Whats the pros about being in the army
Cerrena [4.2K]

Answer:

Benefits that last a lifetime. The Army offers you money for education, comprehensive health care, generous vacation time, family services and support groups, special pay and cash allowances to cover the cost of living.

8 0
3 years ago
Why are funeral home adding dining facilities to the business
Gelneren [198K]
Because they think it will make them more money
5 0
2 years ago
Other questions:
  • g Consider a thin opaque, horizontal plate with an electrical heater on its backside. The front end is exposed to ambient air th
    11·1 answer
  • How can endurance athletes best delay muscle fatigue during training? a. By avoiding sports drinks during exercise b. By eating
    6·2 answers
  • You will create three classes, the first two being Student and LineAtOfficeHour. The instances of the first class defines a sing
    8·1 answer
  • A 24-tooth gear has AGMA standard full-depth involute teeth with diametral pitch of 12. Calculate the pitch diameter, circular p
    5·2 answers
  • Why is oil black and why does oil look black
    10·1 answer
  • Can someone help plz?!?
    5·2 answers
  • Roku internet service providet​
    11·1 answer
  • If i build thing a and thing a builds thing b did i build thing b
    5·2 answers
  • Please help ill mark as brainlest
    13·1 answer
  • Which step in the engineering design process does not come before building a<br> prototype?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!