\电梯此刻具有的功能,人们可以在电梯离开电梯,它扫描他们选择的地板,但是当下一个人选择他们不能即使他们可以选择他们想要的7个楼层中的任何一个,但从0到0的任何地方去。如何使电梯扫描编号
import java.io.IOException;
import java.util.Scanner;
class LiftLogin {
private static int CurrentFloor;
static int RequestedFloor;
private static Scanner next2;
private static int i;
public static <infinite> void main(final String args[]) throws IOException, InterruptedException {
{
Scanner authentification = new Scanner(System.in);
String Passname;
System.out.println("Please enter your Encrypted Passname");
Passname = authentification.nextLine();
System.out.println("Doors Opening");
Thread.sleep(5000);
int attempts = 0;
if (Passname.equals("uzp mwzrrd")) {
System.out.println("Access Granted For Joe Bloggs");
} else if (Passname.equals("ncltr dxtes")) {
System.out.println("Access Granted For Craig Smith");
} else if (Passname.equals("nsctd zyptw")) {
System.out.println("Access Granted For Chris ONeil");
} else if (Passname.equals("pxxl dezyp")) {
System.out.println("Access Granted For Emma Stone");
} else {
System.out.println("Incorrect Passname");
}
{
attempts++;
if (attempts >= 3) {
System.out.println("\nYou've had 3 Attempts, you have been denied Access");
}
}
}
CurrentFloor = i;
next2 = new Scanner(System.in);
int NewFloor;
System.out.println("Current Level:" + CurrentFloor);
infinite loop;
for (;;) {
System.out.println("Please Choose a Floor:");
NewFloor = next2.nextInt();
if ((NewFloor > 7) || (NewFloor < 0) || (NewFloor == 7)) {
System.out.println("\nWrong Floor Selected");
}
else if ((NewFloor <= 7) && (NewFloor > 0) && (NewFloor != 7)) {
for (int i = 0; i <= NewFloor; i++) {
System.out.println("Floor Level: " + i);
Thread.sleep(1000);
}
{
System.out.println("Your at Your Destination - Floor:" + NewFloor);
Thread.sleep(5000);
System.out.println("Doors Closing");
Thread.sleep(1000);
System.out.println("Floor Level: " + NewFloor);
Thread.sleep(1000);
// The code only reprints from 0 i want it to print from the
// NewFloor
}
}
}
}
}
你是什么实际问题? – cheseaux
我怎样才能从用户出去的楼层扫描电梯而不是从0开始扫描? – user3480980
您应该以某种方式存储电梯到达的最后一层,并在此编号处启动'for'循环。 – cheseaux