This is the assignment given to me by my instructor, i dont undetstand pointers and linked lists. Please help!
i am working with putty
The user should be able to work with an ongoing, "current" message by repeatedly choosing following
actions:
m enter a new current message from the keyboard
c encrypt the current message using the Caesar Cipher
C decrypt the current message using the Caesar Cipher
v encrypt the current message using the Vigenere Cipher
V decrypt the current message using the Vigenere Cipher
h help the user by displaying these choices
q quit the program
1.
Here are some requirements for your program:
2.
Your program should be able to handle messages (either as plaintext or as ciphertext) and
3.
Vigenere keys containing any number of characters.
4.
Your program should be able to handle messages (either as plaintext or as ciphertext) containing any commonly printable characters, such as letters, spaces, digits, and punctuation. However, only alphabetic letters should be actively encrypted and decrypted -- other characters should be copied as-is.
5.
Your program should be able to handle Vigenere keys containing any commonly printable characters, such as letters, spaces, digits, and punctuation. However, only alphabetic letters in the Vigenere key should be used to derive offsets -- other characters should be ignored.
6.
When the user enters the current message from the keyboard (either as plaintext or as ciphertext), or enters a Vigenere key from the keyboard, your program should be use the "Enter" key as a sentinel to signal the end of the input.
7.
When your program starts executing, it should automatically start with a current message that is blank (i.e., a message containing 0 characters).
8.
Each time before getting the user's choice, the program should display the current message, surrounded by double-quote symbols. There should be no more than 60 characters on any single line of output -- if more space is needed, the program should skip to the next line, indent 4 additional spaces, and then continue displaying the message.
9.
Whenever the user chooses to encrypt the current message, the program should correctly perform this action, displaying the plaintext, the key, and the ciphertext, and making the resulting ciphertext become the new current message.
10.
Whenever the user chooses to decrypt the current message, the program should correctly perform this action, displaying the ciphertext, the key, and the plaintext, and making the resulting plaintext become the new current message.
11.
Your program should respect the difference between lower-case letters and upper-case letters in the current message. A lower-case letter in the plaintext which is encrypted into the ciphertext, and then decrypted back into the plaintext, should stay a lower-case letter. The same should hold true for an upper-case letter in the plaintext.
12.
All inputs given by the user to your program should undergo data validation to insure that they are correct in data type and range before being used.
13.
You should write this program by extending the LList class that we are currently developing in our CS215 lecture. Each message (whether as plaintext or ciphertext) and each Vigenere key should be stored in an LList object, with each character of that message or key stored as an element inside of a dynamically-created listnode object, where an element has been type-defined as a char.
14.
Here are some hints for making your coding easier:
15.
You can assume that there will always be sufficient memory to allocate storage for new nodes in your linked lists.
16.
Don't use the cin extractor operator (">>") to read characters from the keyboard, since it ignores the "Space" bar and the "Enter" key. Instead, use the get() method of the cin object. For example, if ch is a variable of type char, then:
17.
ch = cin.get();
18.
would read any character from the keyboard (including the "Space" bar or the "Enter" key) into the variable ch .
19.
To see if a particular character variable contains a "newline" character (produced by typing the "Enter" key), you can compare it to the character literal '\n' .
20.
You may find it helpful to understand the ASCII character set when working on this program. To learn more about the ASCII character set, go to
http://www.google.com and search for ASCII, which will bring up several million related pages. Take a look at a few of them, and in particular note the relationship of all of the lower-case letters to each other, and the relationship of all of the upper-case letters to each other.
21.
To convert a character into its associated numeric ASCII code, simply use that character value as if it were an int. For example, if ch is a variable of type char containing the character 'A', and num is a variable of type int, then:
22.
num = ch;
23.
would put the whole number 65 into num (since 65 is the ASCII code for the capital letter "A"). Similarly, a numeric ASCII code can be converted into its associated character value by using that number as if it were a char. So, continuing our earlier example:
24.
num += 2; ch = num;
25.
would put the character 'C' into ch (since num was changed from 65 to 67, and 67 is the ASCII code for the capital letter "C").
26.
Be very careful using pointers! Many programming errors can be traced to the incorrect use of pointers that are undefined (for example, that are uninitialized or are dangling). Be sure that each pointer you are using to access a listnode has directly or indirectly been initialized by using the new operator, and that it isn't NULL, and isn't dangling due to premature use of the delete operator. If you seem to be having trouble getting your pointers to work, a good debugging technique is to draw some sample LList objects by hand, and then trace through your code step-by-step looking for places where your pointers seem to go astray.