0
我知道这是一个noob程序,但我慢慢地感到困惑。 '下'功能将像CD一样行事,“上”功能将像CD一样行事。如何继续制作 - BlueJ Java文件管理器
我不知道如何让用户创建文件或文件夹。我试图使用arrayLists而不是数组,但无法排除错误。任何帮助,将不胜感激。
import java.util.Scanner;
class FileManager {
//array of arrays will go here
String Dir[] = {"UserOne"};
String SystemFolders [] = {"Documents","","",};
String SubFiles [] = {"","","","","",""};
String Nav [][] = { Dir, SystemFolders, SubFiles};
int levelCounter = 0;
public void main(String[]args) {
Scanner sc = new Scanner (System.in);
System.out.println("Enter a command");
String command = sc.next();
if (command.compareTo("down") == 0)
down();
//else if is on the way
}
void down() {
//This will execute when the command is 'down'
System.out.println(Nav[++levelCounter]);
}
void up() {
//This will execute when the command is 'up'. It acts like cd..
System.out.println(Nav[--levelCounter]);
}
}