CSC 321: Data Structures
Fall 2016

HW1: Keypad Verification


The purpose of this first assignment is to refamiliarize you with Java programming and identify any holes in your knowledge/skills. For the first part of the assignment, you will work in a two-person team (with partner assigned by the instructor). This part will be graded in face-to-face meeting with the instructor. The second part will build upon the team-developed code and must be completed independently, with no outside consultation (other than with the instructor, of course).

Both parts of the assignment involve verifying codes (e.g., phone numbers, credit card numbers, security codes) that are entered on a keypad, such as with a phone or ATM.

PART 1: Verifying Codes (2-person team - due 9/1)

For the first part of this assignment, your program should prompt the user for the name of a text file that contains valid codes, one per line. You may assume that codes will be between 1 and 30 characters long, and consist of only the digits 0..9 and/or the characters * and #. After reading in and storing the valid codes, your program should repeatedly prompt the user for codes and display whether each code is valid or not. User input should be terminated by entering a blank line.

For example, suppose the file codes.txt contains the following:

    13579#
    123*45*6789
    1357#9
    1024
    0001010

Your program execution might appear as:

    Please enter the valid codes file: codes.txt
		
    Enter a code to verify (blank line to exit): 1024
        1024 is a VALID code
    Enter a code to verify (blank line to exit): 0001011
        0001011 is an INVALID code			
    Enter a code to verify (blank line to exit): 
        DONE	

PART 2: Fault Tolerance (Independent work - due 9/11)

For the second part of this assignment, you will independently extend your code from Part 1 to accommodate limited user error. In particular, you will recognize codes that vary by having a one character input error (due to a finger slip to an adjacent key). That is, one character in the code is incorrect, and that character is adjacent (horizontally or vertically) on the keypad. For example, the user-entered code 1021 could match the valid code 1024 if the user's finger slipped upward when entering the final character. However, the user-entered code 1028 would not be considered a possible match since the 8 key is not (horizontally or vertically) adjacent to 4.

If there is an exact match for an entered code, this should be reported as in Part 1. Otherwise, all possible (off-by-one) matches should be reported. Note that there may be more than one possible match for an entered code, and these should be reported, separated by commas. Finally, if there is no possible match, your program should report this fact.

Your program execution might appear as:

    Please enter the valid codes file: codes.txt
		
    Enter a code to verify (blank line to exit): 1024
        1024 is a VALID code
    Enter a code to verify (blank line to exit): 0001018
        0001010 is a POSSIBLE code			
    Enter a code to verify (blank line to exit): 000101
        000101 is an INVALID code	
    Enter a code to verify (blank line to exit): 1357##
        13579#, 1357#9 are POSSIBLE codes		
    Enter a code to verify (blank line to exit): 
        DONE	

You must demonstrate good programming style when completing both parts of this assignment, including the appropriate use of Javadoc-style comments for all classes and methods. The javadoc comment at the top of each class must contain a description of the class, the author (using @author), and date (using @version). Each method must have a javadoc comment that describes its overall behavior, each parameter (using @param), and the return value (using @return, if applicable).