Design and implement a simple, interactive shell program that prompt the user for a command, parser the command (you do not need to write a parser) and then execute it. The commands are:
attrib file.
To make the file read only.
import java.io.*;
public class Attrib {
/* Command::
attrib name where name must be the name of a file and its path.
Action:
Makes the file read only.
Errors:
The user enters:
1. attrib Does not type the file name.
2. attrib name but the file does not exist.
3. attrib name but the file is a directory.
When there is an error println a message and return (not exit).
*/
public Attrib(String name){
f(name);
}
private void f(String name){
}
}
copy fileA fileB
To copy fileA into fileB.
import java.io.*;
import java.util.StringTokenizer;
public class Copy {
/* Command::
copy nameA nameB where nameA and nameB must be the name of a files and their paths.
Action:
Copies file nameA to file nameB.
Errors:
The user enters:
1. copy Does not type the file names.
2. copy name Did not type a second file name.
3. copy nameA nameB but the file nameA does not exist.
4. copy nameA nameB but the file nameB alreadyexist.
5. copy nameA nameB but nameA is a directory.
6. copy nameA nameB but the file is a directory.
When there is an error println a message and return (not exit).
*/
public Copy(String name) {
f(name);
}
private void f(String name) {
}
}
delete file
To delete the file.
import java.io.*;
public class Delete {
/* Command::
delet name where name must be the name of a file and its paths.
Action:
delets name
Errors:
The user enters:
1. delet The user did not type the file name.
2. delet name The file name does not exist in the path.
3. delete name But the file name does is a directory.
When there is an error println a message and return (not exit).
*/
public Delete(String name){
f(name);
}
private void f(String name){
}
}

Respuesta :

ACCESS MORE
EDU ACCESS
Universidad de Mexico