代写Lab | Java -JAVA LAB

代写Lab | Java – 这是一个java的常规题目,主要考察java的基本文件操作

JAVA LAB

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:

  • DeclarationOfIndependence.rtf
  • gettysburgAddress.rtf
  • tjefferson.txt
Backup.java
Backup_Driver.java

Complete the Backup.javaprogram

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.

Autolabwill 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.

Leave a Reply

Your email address will not be published. Required fields are marked *