Question
Solve it for java
Question Remember: You will need to read this assignment many times to understand all the details of the you need to write. p
Elevator behaviour: The time it takes the elevator to go from one floor to the next is equal to the time the elevator takes t
Second, it decides if it will open its doors or move to the next floor or do nothing: The elevator will use this time unit to
The total of all trip times, that is, the sum of the times for all employee trips. The time for an employee trip is the time
Modelling the elevator system: The elevator itself is modelled as a stack of employees in this system. The top of the stack i
Elevator: As described above, an instance of this class represents the entire elevator system, including the elevator itself
Queue: You must implement a queue of employees. The queue must be implemented using a circular linked list as described in cl
Additional Notes: You may assume that the input file does not contain any errors. All commands will be valid commands. and th
Elevator dimensions: Number of floors to service: 7 Maximum number of people (load capacity): 5 Elevator begins on floor 0. T
TIme 13: Eievator moves aown to I10or 2 Time 14: Got on the elevator: Employee 6, arrival floor 2, arrival time 0, desired fl
0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class Elevator

{

  private final int MIN_FLOOR = 1;

  private final int MAX_FLOOR = 6;

  private int currentFloor = 1;

  PersonStackElevator ePersonStack;

  Stack lPersonStack;

  Person[] personList;

   

  private void moveUp()

  {

   if (currentFloor < MAX_FLOOR)

   {

   currentFloor++;

   }

  }

  private void moveDown()

  {

   if (currentFloor > MIN_FLOOR)

   {

   currentFloor--;

   }

  }

   

  public void move(Person nextPerson, PersonStackElevator ePersonStack)

  {

   System.out.println("Current floor: " + currentFloor);

     

   if (nextPerson.getFloorEntered() > currentFloor) {

   moveUp();

   }

   else {

   moveDown();

   }

  }

   

  public void load(Person[] personList, int MAX_PERSONS, PersonStackElevator ePersonStack, Stack lPersonStack)

  {

   for (int j = 0; j < MAX_PERSONS; j++)

   {

   if (personList[j].getFloorEntered() == currentFloor && !ePersonStack.isFull())

   {

   ePersonStack.push(personList[j]);

   }

   else if (personList[j].getFloorEntered() == currentFloor && ePersonStack.isFull())

   {

   System.out.println(personList[j].getName() + " took the stairs.");

   stairsCounter++;

   }

   else

   {

   System.out.println("Next to load: " + personList[j].getName());

     

   move(personList[j], ePersonStack);

   unload(ePersonStack, lPersonStack);

   j--;

   }

   }

  }

  ...

}

Add a comment
Know the answer?
Add Answer to:
Solve it for java Question Remember: You will need to read this assignment many times to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is a repost of my question from before. I am having trouble writting the code...

    This is a repost of my question from before. I am having trouble writting the code for this project. Below is the project description with various methods and classes the code in C++ should implement. Project Description The goal of this project is to design and develop C++ code and algorithms to control a bank of elevators, which services many floors and transports people “efficiently ", that is, as per the given specifications. A second goal is to effectively employ...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

  • Need help with java In this program you will use a Stack to implement backtracking to solve Sudok...

    need help with java In this program you will use a Stack to implement backtracking to solve Sudoku puzzles. Part I. Implement the stack class.  Created a generic, singly-linked implementation of a Stack with a topPtr as the only instance variable. Implement the following methods only: public MyStack() //the constructor should simply set the topPtr to null public void push(E e) public E pop()  Test your class thoroughly before using it within the soduku program Part II. Create...

  • Java Project For this assignment, you will write a simulation program to determine the average waiting...

    Java Project For this assignment, you will write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: delete the addfirst, addlast, and add(index) methods and instead include a single add method...

  • Homework #5 - Elevator Simulation - Doubly Linked List The program needs to use a doubly...

    Homework #5 - Elevator Simulation - Doubly Linked List The program needs to use a doubly linked list. Homework #5 - Extra Credit Elevator Simulation Algorithm We are going to develop an algorithm and implement in C++ to simulate a single elevator in a 10-story building. There will be some simplifying assumptions that will make this a bit less complex than a real-world implementation. The number of floors is not important, nor is the number of people getting on or...

  • In Java The fancy new French restaurant La Food is very popular for its authentic cuisine...

    In Java The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of their operations, the Maitre De has hired you to write a program that simulates people waiting for tables. The goal is to determine the average amount of time people spend waiting for tables. Your program will read in a list of event descriptions from a text file, one description...

  • 5. You work on the 13th floor of a 15-floor building. The only elevator moves continuously...

    5. You work on the 13th floor of a 15-floor building. The only elevator moves continuously back and forth between floors 0 through 15 and stopping time at each floor is negligible (a) You find it irritating that every time you want to go home for the day, the elevator is almost always going up when it arrives at your floor. What is the explanation for this? Compute the probability of this occurring. (b) Write the expected value of the...

  • java Object Oriented Programming The assignment can be done individually or in teams of two. Submit one as...

    java Object Oriented Programming The assignment can be done individually or in teams of two. Submit one assignment per team of two via Omnivox and NOT MIO.Assignments sent via MIO will be deducted marks. Assignments must be done alone or in groups and collaboration between individuals or groups is strictly forbidden. There will be a in class demo on June 1 make sure you are prepared, a doodle will be created to pick your timeslot. If you submit late, there...

  • This assignment requires you to create simulations for different scheduling algorithms commonly employed by operating systems...

    This assignment requires you to create simulations for different scheduling algorithms commonly employed by operating systems to achieve multiprogramming. All problems in this assignment assume the following: The simulations you will be creating are for a uniprocessor system (single CPU). Processes in these simulations will require CPU bursts of one or more time units followed by I/O bursts of one or more time units. For simplicity’s sake, when more than one process is executing its I/O burst at the same...

  • C++ -- Event processing simulation using a transaction queue Hi! it is queue simulation please read...

    C++ -- Event processing simulation using a transaction queue Hi! it is queue simulation please read the instructions, write codes, and explain the code with comments. Thank you Transactions enter the system and are stored in a queue. Each transaction represents some work that needs to be accomplished. Servers exist which process transactions. Servers take transactions off the queue and process them. you’re building the simulation framework. The idea is that somebody would take your framework, and add the specifics...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT