3. init_compile.sh
When an instructor downloads the files that a student submits on ong, the files are contained in a zip file having no directories; unzipping the file extracts all of the files submitted by one student into a single directory.
Compiling a Java class that is defined inside a package requires that the source code file be located in a directory tree that mimics the package structure. For example, running the Java compiler in a directory named
Stu Name to compile the class ca.queensu.c.Card requires that the file Card. java be located in the directory ca/queensu/cs (inside the Stu Name directory). If the class is not defined in a package, then the Java file
Copyright By PowCoder代写 加微信 powcoder
must be in the directory Stu Name
Suppose that you have a directory containing one or more subdirectories where each subdirectory is a directory containing the submitted files for a single student. For example, the directory might contain the following
subdirectories:
To compile the Java files in each directory, we need to create the required directory structure inside each student directory and copy the submitted files into their expected directories. For example, if the students were required
to submit the classes
then we would need to create the directory
in each student directory and copy the file A. java into the created directory. Because the file B. java is not declared inside of a package, it can be compiled directly in the student directory.
To create the directory structure, you can use the make_pkg.sh script from Assignment 2 (included in the zip file that you downloaded for this assignment).
Write a script named init_compile.sh that requires one or more input arguments that are fully qualified class names ( ca.queensu.cs.Card or my.pkg.A or B in the examples).
For each student directory located in the current directory, the script creates the required package directories and copies the student’s files into the correct package directories (you can assume that the files to be copied exist
and are readable).
Using the example above, running the command
Using the example above, running the command
init _compile.sh my.pkg.A B
would produce the following directory structure:
# file submitted by Bart, script assumes this file is here
# file submitted by Bart, script assumes this file is here
# directory created by script
# directory created by script
# file copied by script
# file submitted by Homer, script assumes this file is here
# file submitted by Homer, script assumes this file is here
# directory created by script
# director created by script
# file copied by script
# file submitted by Lisa, script assumes this file is here
# file submitted by Lisa, script assumes this file is here
# directory created by script
# directory created by script
# file copied by script
init _compile.sh x Y
would do nothing because × and y are not declared inside of a package.
init _compile.sh my.pkg.A my.C other.D
would create the following directory structure:
Finally, if the script is run with no command line arguments, then it should output an error message to standard error and exit with a status of 1:
$ ./init_compile.sh
At least one fully qualified class name is required
The ZIP file for the assignment contains directories named
package names for testing purposes
each containing the (empty) files A.java
and D.java . You can make
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com