CS 222 Spring 2016

Simple Note Taker, Part I

Due: February 18, Thursday, 11:00 am.

Language: Java

Submission:

  • Your file containing the main method WILL HAVE the name NoteCat.java
  • DO NOT include package names
  • Check your file encoding. It should be UTF-8
  • Commit your code to SVN

Context: You are asked to write a simple command line based note taking program. It will have a small menu to interact with the user. Taken notes will be saved in files with extention .ncat.

User interaction

Provide a console-based interaction for the user to be able to take notes. Your interface should allow the user to:

  1. Show the help menu. This will tell the user how the program is used.
  2. Take a new note and save it with the file extention .ncat.
  3. Show a previously taken note.
  4. Terminate with an appropriate command.
  5. Show error message for wrong commands

Your program should be console-driven, that is it should start up, prompt the user for input, and be able to perform any combination of valid operations without exiting (unless the command exit is provided by the user). Put a sign (e.g. >, $ or #) to indicate the command line prompt.

The list of commands for the command line:

  1. help
  2. exit
  3. new (takes a name)
    1. User enters the command #END after finishing his/her note. This command takes the note until #END keyword and saves it in the file whose name is provided by the user and with the extention “.ncat”
  4. show (takes a name)
    1. An existing note will be printed on the screen. The program will open the note file and read the note from there. Then it will print this on the screen.

Observe the sample run provided below. The program runs continuously until user enters “exit”.

buse@buse src $ java NoteCat
> help
noteCat 0.0.1 - simple console notetaking program
USAGE: noteCat <COMMAND>
OPTIONS:
new <note>   Create new note. End your note with "#END"
show <note>  Display existing note
help         Prints this help menu
exit         Terminates NoteCat
> new note01
Enter your note
I spent my friday to write NoteCat.
#END
> new note02
Enter your note
I hope you enjoy it as much as I did :)#END
> new CAUTION
Enter your note
Pay attention to how notes are taken. For instance, I can put #END here, and it won't save the rest.
> show note01
I spent my friday to write NoteCat.
> show note02
I hope you enjoy it as much as I did :)
> show CAUTION
Pay attention to how notes are taken. For instance, I can put 
> exit
buse@buse src $ 

As mentioned above, you should also be able to print error messages for wrong commands. An example is given below.

buse@buse src $ java NoteCat
> hlp
Invalid menu control command
> ext
Invalid menu control command
> new new note
Invalid number of arguments
> nw note
Invalid note taking command
> exit

HINTS:

  • You should use a Scanner object to read the commands. Reading commands as a line and parsing it is easier from reading them word by word.
  • To read a note taken you can use a BufferedReader object initialized with a FileReader object
  • To read a new note from command line you can use a BufferedReader object initialized with a InputStreamReader object
  • Do not forget to close the streams when you are finished with them or you will run into problems.

Grading

  • Functionality
    • Proper note taking commands: 14
    • Proper CLI: 5
    • Wrong command detection: 6
  • Coding style
    • Names: 15
    • Comments: 5

Penalties:

  • Absence of command line: -10 points
  • Keeping notes in an internal data structure instead of writing to file: -10 points