Last active
November 16, 2015 13:24
-
-
Save dulimarta/a9724202a709497d0d92 to your computer and use it in GitHub Desktop.
CS163-Text-Scrambler-PartB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cis163.text_scrambler; | |
/** | |
* Created by Hans Dulimarta on Fall 2015. | |
*/ | |
public interface GVList<GVElement> { | |
/** | |
* Check if the list is empty | |
* @return true/false | |
*/ | |
boolean isEmpty(); | |
/** | |
* Verify is all items in this list are equal to all items in the other list | |
* @param other the second list to compare this list with | |
* @return true/false | |
*/ | |
boolean equals(GVList<GVElement> other); | |
/** | |
* How many items stored in the list | |
* @return an the integer, the number of items in the list | |
*/ | |
int size(); | |
/** | |
* Return the first item stored in the list | |
* | |
* @return the data contained in the first node | |
* @throws IllegalStateException when the list is empty | |
*/ | |
GVElement front(); | |
/** | |
* Return the first item stored in the list | |
* | |
* @return the data contained in the first node | |
* @throws IllegalStateException when the list is empty | |
*/ | |
GVElement back(); | |
/** | |
* Insert the provided item as the last (new item) in the list | |
* @param item | |
*/ | |
void append (GVElement item); | |
/** | |
* Insert the provided item as the first (new item) in the list | |
* @param item | |
*/ | |
void prepend (GVElement item); | |
/** | |
* Remove a new item (toInsert) after a given item (refItem) | |
* @param toInsert the (new) item to insert into the list | |
* @param refItem the reference item for the insertion | |
* @throws IllegalStateException when the list is empty or the reference item | |
* is not in the list | |
*/ | |
void insertAfter (GVElement toInsert, GVElement refItem); | |
/** | |
* Remove the front item from the list | |
* @return the item just removed | |
* @throws IllegalStateException when the list is empty | |
*/ | |
GVElement removeFront(); | |
/** | |
* Remove the last item from the list | |
* @return the item just removed | |
* @throws IllegalStateException when the list is empty | |
*/ | |
GVElement removeBack(); | |
/** | |
* Remove the requested item from the list | |
* | |
* @param item the item to remove | |
* @throws IllegalStateException when the list is empty or the requested | |
* item is not in the list | |
*/ | |
void remove (GVElement item); | |
/** | |
* Remove all items from the list | |
*/ | |
void removeAll(); | |
/** | |
* Make a duplicate copy of this list | |
* | |
* @return a new list that contains the same items (and order) as those | |
* in this list. | |
*/ | |
GVList<GVElement> makeCopy(); | |
/** | |
* Dump all items in the list to the given string buffer | |
* @param buff the string buffer that will hold the contents | |
* @param sep separator string between items | |
*/ | |
void dump (StringBuffer buff, String sep); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cis163.text_scrambler; | |
import java.util.List; | |
/** | |
* Created by Hans Dulimarta | |
*/ | |
public interface Scrambler { | |
/** | |
* Reformat a paragraph into several lines whose length does not exceed | |
* the requiested column width. This method SHOULD NOT scramble the words. | |
* | |
* @param text the original text given as a long string | |
* @param columnWidth the desired column width of the paragraph | |
* @return lines of the reformated paragraph as a list. | |
* @throws IllegalArgumentException when the columnWidth is too small to fit | |
* the paragraph | |
*/ | |
GVList<String>[] reformat (final String text, int columnWidth); | |
/** | |
* Scramble a paragraph | |
* | |
* @param origText the original paragraph text. Each string in the List | |
* represents one line of text in the paragraph. | |
* @return | |
* @throws IllegalArgumentException when the array origText has no elements | |
*/ | |
GVList<String>[] scramble (final GVList<String>[] origText); | |
/** | |
* Unscramble a paragraph | |
* | |
* @param scrambledText the scrambled paragraph text. Each string in the List | |
* represents one line of text in the paragraph. | |
* @return the unscrambled version of the paragraph with all the filler | |
* strings removed. | |
*/ | |
GVList<String>[] unscramble (final GVList<String>[] scrambledText); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment