Class MessageApp
Object
MessageApp
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMessageApp(ArrayList<OpenMessage> messages) Initialize the ArrayList of OpenMessages -
Method Summary
Modifier and TypeMethodDescriptionvoidComposes an OpenMessage.voidgo()Runs the program, keep going until user input is "x".static voidvoidprocessCommand(String command) Checks the command (options from the menu) and calls appropriate methods for its functionality.private StringAsks user for what type of search and what they are searching for, then returns the message if found.
-
Field Details
-
messages
-
view
-
-
Constructor Details
-
MessageApp
Initialize the ArrayList of OpenMessages- Parameters:
messages- ArrayList of OpenMessages
-
-
Method Details
-
go
public void go()Runs the program, keep going until user input is "x". If "x" is entered, stop the program. -
processCommand
Checks the command (options from the menu) and calls appropriate methods for its functionality. Does nothing if a command is not known (no need for help dialog). Add additional check for if command is "c". If so, compose a message and print a statement such as "Message composed." Remember to use helper methods! The composeHelper() method is there to keep clutter out of the processCommand() method.- Parameters:
command- command entered by user
-
searchHelper
Asks user for what type of search and what they are searching for, then returns the message if found. Implemented in Lab 10.- Returns:
- String that is a list of all messages found that satisfy the search
-
composeHelper
public void composeHelper()Composes an OpenMessage.Implementation Hints:
- Get input from user about TO, FROM, SUBJECT, and BODY information.
- Create a new OpenMessage object with that stored information and add it to your OpenMessages ArrayList.
- Ask user what file they would like to write the message to.
- Inside a try/catch block, make a new PrintWriter to the file the user chose.
- Make a new Key object and initialize it with id = 1, shift = 3. NOTE: We are hard-coding in the Caesar Cipher with a shift of three here, we will change this in Lab 14 to make the encryption process more secure!
- Encrypt the message using the message's toString() and the Key.
- Print to the PrintWriter both the encrypted and decrypted message.
- Don't forget to close your PrintWriter and catch a FileNotFoundException!
-
main
-