\電梯此刻具有的功能,人們可以在電梯離開電梯,它掃描他們選擇的地板,但是當下一個人選擇他們不能即使他們可以選擇他們想要的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