Question
Write c++ code using the following classes. Use vigenere cipher, follow the hierarchy diagram for inheritance. Define your classes in header file and implement in
Write c++ code using the following classes. Use vigenere cipher, follow the hierarchy diagram for inheritance. Define your classes in header file and implement in .cpp file. You can test your code using the main.cpp file. Your output should follow the one provided.
//Exception.h
#include using namespace std;
class Exception { //data member protected: string error; public: //constructor Exception(const string& message) { error=message; //set the message } //function getError string getError() { return error; //returns error message } };
//Cipher.h #include
using namespace std;
class Cipher { //abstract or pure virtual functions below public: virtual string encode(const string&)=0; virtual string decode(const string&)=0; };
//main.cpp
#include #include
#include "Vigenere.h"
using namespace std; /* The following main tests the functionality of various ciphers.
Use at your own discretion, and feel free to extend and/or modify in any way.
This file will be overwritten by the automarker if submitted. */
void testCipher(Cipher& cipher, const string& text) { try { string encoded = cipher.encode(text); cout
int main() { string shortText="Top Secret";
string longText="According to Larry Wall, the original author of the Perl programming language, there are three great virtues of a programmer; Laziness, Impatience, and Hubris. Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don't have to answer so many questions about it. Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don't just react to your needs, but actually anticipate them. Or at least pretend to. Hubris: The quality that makes you write (and maintain) programs that other people won't want to say bad things about."; Vigenere vig("BANANA"); testCipher(vig, shortText); testCipher(vig, longText); try { vig.setCodeword("?"); } catch(Exception e) { cout
testCipher(vig, shortText); testCipher(vig, longText); try { vig.setCodeword("this-is-not-a-code-you're-looking-for"); } catch(Exception e) { cout
testCipher(vig, shortText); testCipher(vig, longText);
OUTPUT
v1?A"'&446 Top Secret
c%21A&,06AC1Bm04A;Bx0.;MB67'N15+6+=#/A07C*24N15A7*4A~'5.N2A1*40/)A#0/44iAn#I+='65ZAw/3#C+40&'ZA00'Av714,5\Az#=+='B5\A#*4A470.867N)2AC1N)5'06N')(>4CA71N44&8%4A>8(40.;A(0446;B'G240'+C7A'PAw6N/$-45N;27N9A+7'N.0$24[508,06A?42)A#2;'B98.;A)+=&N76'57;A$03A31&77N&20U6N*$84AC1B#=5F'5AB1N/$0HA@7(5C+>06A0$>77A86\Ak/?#C+(02'hAv*4A00*'AAH18A5'4.B97'=A7*4A2102D644B+BA1',06A;#=;\A#*,5N/0-(5N;>7B9A+C'B2A164$/BAC*$6N&>0I6N,D57AA'0%7AC1N;27AA='(&BMN$86N#268#;.HA$0C+2+3#C'N6+'ONi8$A+B[Bu7'N38#;+C;B67#CA0#:'BAA6#HA1#'AC*80*5N#1186\ According to Larry Wall, the original author of the Perl programming language, there are three great virtues of a programmer; Laziness, Impatience, and Hubris. Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don't have to answer so many questions about it. Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don't just react to your needs, but actually anticipate them. Or at least pretend to. Hubris: The quality that makes you write (and maintain) programs that other people won't want to say bad things about.
The codeword provided is not going to generate a safe encryption
The codeword provided is not going to generate a safe encryption
AU^oBRI`Uc Top Secret
.IQ_aQO\WnaUmUaYe^b^TXO]\VTUo[NTUePTKyocUK`UnNXSocUXSUnTXSQcl\WbcbKao^SeOo__UUbPZSSb*l2OjX[Kaczl/[`PaOS^RRqmQ]Qe6eQ_Oa}n9GhY]RYa*nANSo`bGZYcfebXPae[QZRYmi^beU_naUmWaRGboTSL]bclZ]oaRJcSTlUdUaNRZoT[K`WhlKf`T[JWdd_K{o8ae[QZRYmi^beebXaKm\POU`|bN\W^VlV`_V_G[cnaNOdn\ZVUalVS__YKmgXYRmVX[JmebRLc NTRoS\Ic]T[ZmgWNZmi^beeb^aKmc^l_]enQU\vclNOfTlZ]oP[YeUalY]o\NTgo`bKadX\TaoPOUcdnVZ{o8ZVOdXRTQU)l:VUnNTUUal_]enSKS dNS^naNSoR\S^ecRXmYblHSY]TeZQifsmDWVYm]PXKaoh\[mgaVZSo__UUbPZYmdWNZmT^[lboYbYboaRGQdnaUmi^bXm^TRJa{nO[boPPZcQ[Y_mQ]aOQY_NZSocUK[}n According to Larry Wall, the original author of the Perl programming language, there are three great virtues of a programmer; Laziness, Impatience, and Hubris. Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don't have to answer so many questions about it. Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don't just react to your needs, but actually anticipate them. Or at least pretend to. Hubris: The quality that makes you write (and maintain) programs that other people won't want to say bad things about.
IXZs`OW Td Top Secret
6LMc N]{Voi|aYEbW_-QQbs~e"UUo[\XOvUQ_tJ_huYf-^Vt"Jrc@JXyy`hvZXnZ]YZQnTnUWhVPO -^ aUtnTrcdMXr_o]yXG"lfY^^dM!f_YtJid Y[ P]brTHc
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started