Question
Program in C++ Attach all header, source and driver files separately to your submission in eLearning A file filter reads an input file, transforms it
Program in C++
Attach all header, source and driver files separately to your submission in eLearning
A file filter reads an input file, transforms it in some way, and writes the results to an output file. For this assignment, you will three different file filters.
Create an abstract file filter class that defines a pure virtual function for transforming a character.
The pure virtual function should have the following header
void doFilter(ifstream &in, ofstream &out)
All three derived classes will define this function
This function will handle the file filtering duties
Create three classes all derived from the abstract class. File filter 1 - EncryptionHas a single member variable named key
The key will be used to modify the ascii value of a character
It may be a positive or negative number
Has an overloaded constructor that takes an integer value and stores it in the key
The default key value is 5
Define the doFilter function to read each character from a file, convert the characters and write the characters to another file
Add the key value to the ASCII value of each character
The resulting number should be between 32 and 126. If the value is outside this range rollover the number.
For example if the number is 127 that rolls over to 32, 128 is 33, 129 is 34, etc.
Same applies for numbers below 32. 31 is 126, 30 is 125 etc.
File filter 2 - Uppercase
Create a function with the following header:
char transform(char ch)
Check if a letter is lowercase
If the letter is lowercase, convert it to uppercase
do not use the character functions from Chapter 10.
Define the doFilter function to read each character from a file, convert the characters to uppercase (if not already) and write the characters to another file
File filter 3 - Copy
Define the doFilter function to read each character from a file and write the characters (unmodified) to another file
Create a driver program that tests each class.
Other than the encryption class there should be no attributes, constructors or destructors. The main thing here is to redefine the pure virtual function.
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