The goal of this lab is to practice working with ArrayList
s by
completing a Document
class that represents a text
document as an ArrayList
of String
objects,
where each entry in the ArrayList
corresponds to a single
line of text.
Since we will be working with a command-line Java application, you should not use Eclipse for this lab. You can edit the Java files using the gedit text editor and compile your code in the terminal. The Web-CAT submission tests for this lab won't run Checkstyle, so you don't need to worry about low-level formatting issues.
As a reminder, you can follow the following steps to compile and execute a Java program in the terminal:
$ cd the_directory_where_your_code_is_stored $ javac File1.java File2.java ... $ java File1
This example assumes that File1.java
contains the
main method for the application.
The following files are provided:
Document.java
UNFINISHED
DocumentTestDriver.java
This is a simple driver class for testing Document.java
.
Take a minute to look over this code to get a better idea of the
expected behavior.
Editor.java
This is an
editor application that provides a command-line interface to
the Document
class.
Download the files above and complete Document.java
so that all methods conform to the Javadoc comments. Test your completed
file by running the two provided application programs.
Your solution should use only enhanced for loops.
Submit your completed version of Document.java
through
Web-CAT. Style checking is turned off, and you have an unlimited
number of submissions. If you have trouble with your submission, you
may find it helpful to look at the JUnit submission tests:
DocumentTest.java
.