Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ LANGUAGE!! Define three classes. Each one should be in a separate file. You can choose to define the class and its functions inline, all

C++ LANGUAGE!!

Define three classes. Each one should be in a separate file. You can choose to define the class and its functions inline, all in a header file, or have a .h and .cpp file for each class.

  • Abstract base class with the following:
    • A variable to hold an encrypted message. This variable should be a string which is initialized in the constructor.
    • A status variable that will tell whether the message was loaded successfully.
    • A constructor that receives one parameter: a string variable with a file name and uploads its content to the string variable that is supposed to store it.
    • A pure virtual function called decode. This function will be defined in derived classes.
    • A function that prints the message on the screen
  • A derived class that implements a version of decode according to the following algorithm:
    • 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 second derived class that implements a version of decode according

    algorithm known as "rotational cypher". In this encryption method, a key is added to each letter of the original text. For example:

    Cleartext: A P P L E Key: 4 4 4 4 4 Ciphertext: E T T P I

    In order to decode, you need to subtract 4.

I will provide a program that tests your classes.

How to split the workload:

Each group member should be responsible for one class. You all must make sure they compile and run together.

Testing/Output:

A main program that can be used to test your classes can be found here. Please use the following files as input text files: EncryptedA.txt and EncryptedB.txt

The output should be printed on the screen. Attach the output of your program as a comment at the end of your source code.

Turn in:

Encrypted.h, CypherA.h and CypherB.h (corresponding .cpp files optional). Only one person in the group should turn in the assignment for the group.

ALL files should have the group # and the names of ALL group members.

//MAIN FILE

#include #include #include

#include "CypherA.h" #include "CypherB.h"

using namespace std;

int main(int argc, const char* argv[]) {

string filename; char option;

cout << "Enter file name to be decoded with algorithm A: "; cin >> filename;

CypherA messageA(filename);

if (messageA.isEmpty()) { cerr << "ERROR: Message could not be read." << endl; } else { messageA.decode(); cout << "Decoded message: "; messageA.print(); cout << endl << endl;; } cout << "Enter file name to be decoded with algorithm B: "; cin >> filename;

CypherB messageB(filename);

if (messageB.isEmpty()) { cerr << "ERROR: Message could not be read." << endl; } else { messageB.decode(); cout << "Decoded message: "; messageB.print(); cout << endl; }

return 0; }

EncryptedA:

ifqkwxcadf ar cei fpoi masif cd cei xkdqirr du pxxnwafm pf pnmdkaceo cd p oirrpmi, teaqe rqkpohnir cei gpcp af ac-oplafm ac sikw gauuaqvnc pfg caoi qdfrvoafm, au fdc xkpqcaqpnnw aoxdrrahni, cd gigvqi cei dkamafpn masif dfnw cei ifqdgig gpcp. afxvcr cd cei pnmdkaceo cwxaqpnnw afsdnsi pggacadfpn riqkic gpcp qpnnig liwr, teaqe xkisifcr cei oirrpmi ukdo hiafm giqdgig-isif au cei pnmdkaceo ar xvhnaqnw lfdtf.

EncryptedB:

mr e wdqqixvmg irgvdtxmsr epksvmxlq, fsxl xli wirhiv erh xli vigmtmirx ywi xli weqi oid (orsbr ew xli wigvix oid) xs irgvdtx erh higvdtx xli qiwweki. sri aivd fewmg wdqqixvmg irgvdtxmsr epksvmxlq mw orsbr ew xli vsxexmsrep gmtliv. mr xlmw epksvmxlq, xli wirhiv wmqtpd "ehhw" xli oid xs iegl glevegxiv sj xli gpievxicx qiwweki xs jsvq xli gmtlivxicx. jsv iceqtpi, mj xli oid mw 2, "e" bsyph figsqi "g", "f" bsyph figsqi "h", erh ws sr. xli vigmtmirx bsyph xlir higvdtx xli qiwweki fd "wyfxvegxmrk" xli oid jvsq iegl glevegxiv sj xli gmtlivxicx xs sfxemr xli svmkmrep qiwweki.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago