Sie sind auf Seite 1von 2

CPSC 350: Data Structures Fall 2013 Programming Assignment 1: C++ Review Due: Sept. 2nd, 2013.

11:59pm The Assignment For this assignment you will be writing a C++ program for parsing encrypted files, determining the encryption format, and writing out the decrypted content. A simple encryption technique is to start with the alphabet and simply rotate every character by a fixed amount (an offset). Given encrypted text, this offset can be computed by determining the most frequent character, and comparing its position to the character e (the most frequent letter in the English language). For example, if g is the most frequent character in the encrypted text, the alphabet has been offset by 2 since g is 2 letters away from e. Note that punctuation and white space is ignored in this scheme. You should start by designing a class to encapsulate the encryption/decryption logic. Your class should provide a method that takes a path to a directory of encrypted files as input. (Assume the files end with the .enc extension.) After parsing the files and determining the offset, the method should write decrypted versions of the files into the same directory, but with a .dec extension. During the conversion process the cases of the letters should be preserved. Your class should also provide another method that takes a decrypted string as input, and prints its encrypted format to standard output. Another method should do something similar with encrypted strings. Note that these methods can only be invoked once an encryption scheme has been learned from a set of files. Thus, your program will have to do sufficient error checking to prevent usage errors. Once your class is written you should write a main program that displays a menu asking the user if they way to decrypt a directory, encrypt a string, or decrypt a string. These options should exercise the methods of your class until the user selects an option to quit. Hints In C++ it is trivial to convert chars to their integer ASCII codes. You can simplify your programs logic by working with ASCII codes rather than the chars they represent. (In other words, you dont need a bunch of conditional logic to determine what letter is being processed.) To store the letter frequencies you should use a fixed size array. I will do my best to break your program when I run it. You should design it to be robust. The Rules - You may NOT use any data structures other than arrays. Hopefully this will convince you that data structures make programs more efficient and easier to write. (Though I suspect you know this already) Of course, to do the file processing you may use any of the C++ IO classes. - For this assignment, you must work individually. You may work in pairs in future assignments, but I want you all to write some code on your own first.

Develop using any IDE you want, but make sure your code runs correctly with g++. Make sure to provide a Makefile so I can build your code easily. (See Assignments for a sample Makefile.) Feel free to use whatever textbooks or Internet sites you want to refresh your memory with C++ IO operations, just cite them in a README file turned in with your code. All code you write, of course, must be your own.

Due Date This assignment is due at 11:59pm on 9-2-2013. Submit it using Blackboard following the submission instructions available under Information. Well spend a few minutes discussing your experience with this assignment in class. Grading Grades will be based on correctness, adherence to the guidelines, and code quality (including the presence of meaningful comments). An elegant, OO solution will receive much more credit than procedural spaghetti code. I assume you are familiar with the standard style guide for C++, which you should follow. (See the course page on Blackboard for a C++ style guide.)

Das könnte Ihnen auch gefallen