代做Lab | Java代写 – java的一般的练习题目
For this assignment, you will create a program that will create backup copies of a list of files. We will test your program with the following files:
Complete the Backup. java program
Backup.java has been partially written, and you will need to complete the methods left incomplete. This class will be called by a program called Backup_Driver.java which tests to ensure that you have dealt with the various issues that might occur with the Backup.javaclass. Note: Backup.java does not have a main method. It is instantiated and used by Backup_Driver.java.
Note: Backup_Driver.java is there for your convenience to help you in testing your Backup.java program. The JUnit tests run in Web-CAT are more thorough.
Your task is not only to get the program to function, but to make sure that it will function no matter what data is sent. The start() method expects an array of Strings. It is possible that the array may be null or empty. It is also possible that the array is sparsethat is, some elements are empty (or null). You need to handle these issues in the start() and backup()methods. The copyFile() method is fully functional and handles the issue of the existence or non-existence of a file to be copied.
Auto lab will use a JUnit test that I wrote to test the backup() and buildFileArray()methods. These methods return boolean values if the method completes successfully. Since the backup() method calls the copyFile() method, there is no need to test that separately.
The buildFileArray() method will report success == true if:
- The String array is not null and not empty, and
- Each element of the String array is not null and not empty
The backup() method will report success == true if:
- The File array is not null and not empty, and
- Each element of the File array is not null, and
- Each element of the File array does not represent an empty String (e.g., new File( "" ) ), and
- All files actually exist and thus can be copied
- Note: a single element array should succeed if all of the above apply.