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...

  • 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...

  • 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...

  • Hi! it is c++ queue simulation please read the instructions, write codes, and explain the code...

    Hi! it is c++ 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 for whatever type of system it was going...

  • 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...

  • Write a C++ code based this question n this assignment you will create three additional functions...

    Write a C++ code based this question n this assignment you will create three additional functions for each one of the data structures created in class. You will be provided with a header file which you will modify and a demo program for each data structure. If your functions are implemented correctly the demo programs should compile and execute correctly. Part 0 (Comments) 1. Over the course of the semester we have discussed comments for each data structure. Please add...

  • I NEED THE CODE FOR PART 2-MATH MODELING CLASS USING MATH LAB in thrve posed elevator...

    I NEED THE CODE FOR PART 2-MATH MODELING CLASS USING MATH LAB in thrve posed elevator problem, your assistant notified you that there are 60 workers operating on each of 5 floors atop the ground floor in your office building - 300 in total. The elevator occupancy is 10 people, and there are 3 elevators in total. In the worst-case scenario in terms of total transition time, on each elevator ride at least one person is getting off at each...

  • Hi I need a fix in my program. The program needs to finish after serving the...

    Hi I need a fix in my program. The program needs to finish after serving the customers from the queue list. Requeriments: Headers: DynamicArray.h #ifndef DynamicArray_h #define DynamicArray_h #include using namespace std; template class DynamicArray { V* values; int cap; V dummy; public: DynamicArray(int = 2); DynamicArray(const DynamicArray&); ~DynamicArray() { delete[] values; } int capacity() const { return cap; } void capacity(int); V operator[](int) const; V& operator[](int); DynamicArray& operator=(const DynamicArray&); }; template DynamicArray::DynamicArray(int cap) { this->cap = cap; values =...

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
ADVERTISEMENT