Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Solution Description You will be writing a class called Command Prompt.java. Your goal is to create a program that acts the same way that Command
Solution Description You will be writing a class called Command Prompt.java. Your goal is to create a program that acts the same way that Command Prompt does. Requirements We are first going to start in our home directory :\user\georgeburdell The program should terminate when the user inputs c cd command You should have 3 folders in your home directory and within those folders, one folder each o Desktop Take TheT o Documents 1331 o Downloads Ramblin Wreck You can expect the user to only input cd .. or cd foldername cd .. will move backwards one directory (see Sample Output for example) This means that the last directory should be removed from the pathway cd foldername should move forwards one directory o This means that the folder name should be concatenated (hint hint) to the pathway dir command This command should tell you what folders are in the directory you are in. You must print out the list of folders within a directory as shown in the sample output. The user should not be allowed to cd into folders that are not in the directory when you use the dir command If there are no folders in that directory, nothing should be printed out Example: . :\user\georgeburdell\Desktop cd TakeTheT :\user\georgeburdell\Desktop\Take TheT dir :\user\georgeburdell\Desktop\TakeTheT . Note that whatever the users current path is gets printed out again even though there was nothing in the directory. Make sure to do this as it needs to be there when the user inputs their next command. cls command This command will clear out everything previously in the Command Prompt Your implementation should not allow the user to see any previous commands Invalid Inputs It is possible for the user to input either an invalid command or folder name if the foldername in the cd command does not exist within the directory, print out: No such file or directory found o Stay in the directory you were already in. If the user inputs an invalid command, print out o Command not found We highly recommend you look at the Java API for String and Scanner to help you along with this homework. There may useful methods listed there that aren't talked about in the modules. We recommend that you do not use Scanner's nextLine() method. Sample Output :\user\georgeburdell cd .. :\user dir georgeburdell :\user cd georgeburdell :\user\georgeburdell dir Desktop Documents Downloads :\user\georgeburdell cd Downloads :\user\georgeburdell\Downloads dir RamblingWreck :\user\georgeburdell\Downloads cd .. :\user\georgeburdell cd Desktop :\user\georgeburdell\Desktop cs Take TheT Command not found :\user\georgeburdell\Desktop ^c
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started