Java help
Queens College Department of Computer Science
CSCI 212 – Object-Oriented Programming in Java – Spring 2013
Project 2
Assigned: 18 March 2013 Due: 8 April 2013
Roman Numeral Lists Summary:
• Extend JFrame to create a class called RomanNumeralGUI. It should have a GridLayout of one row and two columns.
• Adapt the linked list (as shown in lecture) to create a class called RomanNumeralList. Instantiate two linked lists, one called inOrder and one called sorted.
• Read RomanNumerals from a file (as in Project 1) and, if valid, add them to the inOrder list (append) and the Sorted list (insert in ascending order).
• Display the unsorted RomanNumerals in the left column of the JFrame, and the sorted ones in the right column.
Class RomanNumeralList should have (at least) the following methods:
RomanNumeralList() constructor void append (RomanNumeral rn) add a node containing rn to the end of the list void insert (RomanNumeral rn) add rn to the list so that the list remains sorted according to the definition of compareTo(). Boolean equals(Object other) override of inherited method from class Object String toString() returns a String containing the data of each node
of the list separated with new line (\n) int length() returns the number of nodes in the list RNLinkedListIterator reset() creates an iterator for the linked list
You will need to create a ListIterator to traverse the list. Here is a sketch of the algorithm for the main program:
RomanNumeralList inOrder, sorted; RNLinkedListIterator rnIterator; inOrder = new RomanNumeralList(); sorted = new RomanNumeralList(); while not end of file
s = line read from file;
CS 212 Project 2 Spring 2013 Page 2
rn = new RomanNumeral(s); inOrder.append(rn); sorted.insert(rn);
rnIterator = inOrder.reset(); while (rnIterator.hasNext()
add rnIterator.next() to layout column 0; rnIterator = sorted.reset(); while (rnIterator.hasNext()
add rnIterator.next() to layout column 1;
Documentation As in project 1, your code should contain comments before important structures such as while loops, if statements, and at the beginning of private helper methods. These comments should describe the purpose of the code that follows. Javadoc Each class (except for the main program) should have appropriate javadoc (see the guidelines on Blackboard). Submit a jar file. Rather than upload all the files above separately, we will use Java’s facility to create the equivalent of a zip file that is known as a Java ARchive file, or “jar” file. Instructions on how to create a jar file using Eclipse are on Blackboard. Create a jar file called Project2.jar and submit that one file through Blackboard. You should submit (at least) the following classes: Project2.java RomanNumeral.java RomanNumeralNode.java RomanNumeralList.java RNLinkedListIterator.java RomanNumeralGUI.java
- Project 2