CS 222 Spring 2016

Simple Note Taker, Part III

Due: March 03, 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

Task 1

Add two new commands to your CLI: list and rename

  1. list command takes a note name as an argument or “all” to list all the notes.
    • When user enters “list all”, names of all notes taken is printed on the screen.
  2. rename command takes a note name as an argument, it renames this note.
    • Ask the user for a new name for renaming.
  3. Expand your help menu with these new commands.

Task 2

Print error messages on the screen for these commands. Apart from error commands you are required to:

  1. For list command:
    • Warning message: Print something like “You don’t have any notes yet” when “list all” command cannot find any notes.
  2. For rename command:
    • Warning message: After you read the command “rename note”, ask for the new note name. Note name cannot contain space character, any other character (unless it’s turkish) is allowed. Warn the user with a message like “Invalid note name for renaming. It contains ‘ ‘.” if it contains spaces. Until a decent name for renaming is supplied, keep asking the user.
    • Also user cannot rename a note if a note with the new name already exists on the system. (See the last example where I try to rename scarlet to pink in the run given below)

See the example given below for Task 1 and Task 2. Make sure that you cover all errors and warnings listed here.

buse@buse src $ java NoteCat.NoteCat
> help
noteCat 1.0.0 - simple console notetaking program
USAGE: noteCat <COMMAND> [DATA]
OPTIONS:
new    [note] Create new note
append [note] Append to an existing note
show   [note] Display existing note
rename [note] Rename existing note
delete [note] Delete existing note
list   [all ] List all notes taken so far.
help          Prints this help menu
exit          Terminates NoteCat
> list all
You have no taken notes yet.
> new red
Enter your note
red#ENDcrimson
> show red
red
> list all
red.ncat
> list red
red.ncat
> new pink
Enter your note
pink#END
> list all
red.ncat
pink.ncat
> list blue
File does not exist
> list red now
Invalid number of arguments
> lst red
Invalid note taking command
> list
Invalid menu control command
> rename red
Enter the new note name
crimson
> list red
File does not exist
> list all
crimson.ncat
pink.ncat
> show crimson
red
> list all
crimson.ncat
pink.ncat
> rename blue
Enter the new note name
azure
File does not exist
> rnme  
Invalid menu control command
> rename orange yellow
Invalid number of arguments
> ren blue
Invalid note taking command
> list all
crimson.ncat
pink.ncat
> rename crimson
Enter the new note name
sca rlet
Invalid note name for renaming. It contains ' '.
scarlet
> show scarlet
red
> list all
scarlet.ncat
pink.ncat
> rename scarlet
Enter the new note name
pink
File already exists
> exit
buse@buse src $ 

Task 3

Refactor your code. In addition to appropriate naming, clean and short and well-defined functions, apply what you have learnt from formatting lecture. Make sure that you don’t have any code smells in your code.

Grading

  • Functionality
    • Proper note taking commands: 8
    • Proper CLI: 2
    • Wrong command detection and errors: 5
    • Warning messages: 5
  • Coding style
    • Names: 8
    • Functions: 10
    • Formatting: 12

Penalties:

  • Absence of command line: -10 points
  • Keeping notes in an internal data structure instead of writing to file: -10 points
  • Using predefined paths for notes specific to your computer: -10