Lab 4 c++ cs visual studio
Programming
Lab 4
In cryptography, encryption is the process of encoding a message or information in such a way that only authorized parties can access it. In this lab you will write a program to decode a message that has been encrypted.
Define a class with the following:
- A variable to hold an encrypted message. This variable should be a c-stringwhose storage space will be allocated by the constructor.
- A status variable that will tell whether the message was loaded successfully.
- A constructor that receives two parameters: a string variable with the file name and an int variable with the maximum number of bytes that can be uploaded (use this parameter to dynamically allocate space for the variable that will hold the message). You must be careful to not read more characters than you allocated for the c-string variable or you risk having your program crash. After you successfully read the message from the file, set the value of the status variable to true.
- A destructor that will free the memory allocated in the constructor.
- A function that returns the value of the status variable. The value of this variable should always be checked prior to decoding, since trying to decode an empty string may result in your program crashing.
- A function that decodes the message. Use the following key to decode:
- input character: abcdefghijklmnopqrstuvwxyz
- decoded character: iztohndbeqrkglmacsvwfuypjx
- That means each ‘a’ in the input text should be replaced with an ‘i’, each ‘b’ with a ‘z’ and so forth.
- A function that prints the message on the screen
I will provide a program that tests your class. Turn in Encrypted.h and Encrypted.cpp.
Rubric
Some Rubric (1)
| Criteria | Ratings | Pts | ||
|---|---|---|---|---|
|
This criterion is linked to a Learning OutcomeDocumentation |
|
5.0 pts |
||
|
This criterion is linked to a Learning OutcomeGeneral structure of the class |
|
5.0 pts |
||
|
This criterion is linked to a Learning OutcomeConstructor, Destructor |
|
10.0 pts |
||
|
This criterion is linked to a Learning OutcomeMember function that returns the value of the status variable |
|
5.0 pts |
||
|
This criterion is linked to a Learning OutcomeMember function that decodes the message |
|
10.0 pts |
||
|
This criterion is linked to a Learning OutcomeMember function that prints the message on the screen |
|
5.0 pts |
||
|
This criterion is linked to a Learning OutcomeStyleExamples: avoids repetition of code by defining functions and using loops; defines constants for arrays sizes and their access; makes sure to not overstep array boundaries; there are no global variables, labels and goto statements; cod is nicely indented. |
|
5.0 pts |
||
|
This criterion is linked to a Learning OutcomeOutput attached as a comment at the end of source code |
|
5.0 pts |
||
|
Total Points: 50.0 |
||||
