My code is basically like an elevator using dynamic queues. I want to imitate the way a elevator works using code. I set it up according to user input:
After that, I check the numbers to make sure the floor number is in the range form 1 and number of floors. I put the numbers in a queue and when another number is added, I put the initial number in a dynamic queue.
I want to print all the numbers out that are passed on the way to the destination floor and I'm stuck right here. I want to print out the queue so I can see if it is working but I don't know how. I have to implement dynamic queue. So there is no getting rid of it.
import java.util.*;
public class ElevatorsCopy {
public static void main(String[] args) {
Scanner floors = new Scanner(System.in);
int floorMax;
int floorNum;
int n = 0;
String floorCount = " ";
System.out.println("How many floors are in the buiding");
floorMax = floors.nextInt();
System.out.println("There are " + floorMax + " floors in this building");
System.out.println("Which floor would you like to go to?");
floorNum = floors.nextInt();
System.out.println("Going to the " + floorNum + " floor.");
Queue<Integer> destFloor = new LinkedList<Integer>();
PriorityQueue<Integer> priorityFloor = new PriorityQueue<Integer>();
for ( int i =0 ; i <= floorMax; i++)
{
destFloor.add(i);
for(int j =0; j <= floorMax; j++)
{
if(j <= floorMax)
{
destFloor.add(j);
priorityFloor.add(i);
}
else{
System.out.println("That floor does not exist.");
}
}
}
}
}