7 Replies - 444 Views - Last Post: 20 February 2020 - 06:41 PM Rate Topic: -----

#1 [email protected]   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-February 20

File Filter

Posted 20 February 2020 - 04:28 PM

I need help with this assignment. I know pure basics cin, cout, type stuff. I don't know this advanced stuff.

A file filter reads an input file, transforms it in some way, and writes the results to an output file. Write an abstract file filter class that defines a pure virtual function for transforming a character. Create one subclass of your file filter class that performs encryption, another that transforms a file to all uppercase, and another that creates an unchanged copy of the original file.

The class should have a member function

void doFilter(ifstream &in, ofstream &out)

that is called to perform the actual filtering. The member function for transforming a single character should have the prototype

char transform(char ch)

The encryption class should have a constructor that takes an integer as an argument and uses it as the encryption key.

#include <iostream>
#include <fstream>
#include <cctype>
using namespace std;

//  This is the abstract Filter class. Concrete derived classes will override the //  transform member function class Filter


{
public:
    void doFilter(WHAT SHOULD YOU PUT IN HERE);
protected:
    virtual char transform(char ch) = 0;
};


//   Filter::doFilter  Performs actual filtering.

void Filter::doFilter(WHAT SHOULD YOU PUT IN HERE)


// Uppercase subclass filter class


int main( )

// Explain the program


// Echo the input file

// Get name of output file

// Open the output file

// Process

// Close output file and reopen for  reading so we can  print

// Close all files


//   Print file

// Print the file contents

// Go back to beginning of file for further processing





Is This A Good Question/Topic? 0
  • +

Replies To: File Filter

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15564
  • View blog
  • Posts: 62,309
  • Joined: 12-June 08

Re: File Filter

Posted 20 February 2020 - 05:21 PM

What have you tried, thought about, or considered?
Was This Post Helpful? 0
  • +
  • -

#3 [email protected]mail.com   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-February 20

Re: File Filter

Posted 20 February 2020 - 05:24 PM

all i have is thhe skelton of code that i provided. my knowledge of c++ is very basic

This post has been edited by Skydiver: 20 February 2020 - 06:23 PM
Reason for edit:: Removed unnecessary quote.

Was This Post Helpful? 0
  • +
  • -

#4 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7289
  • View blog
  • Posts: 24,666
  • Joined: 05-May 12

Re: File Filter

Posted 20 February 2020 - 06:08 PM

Also posted here.
Was This Post Helpful? 1
  • +
  • -

#5 [email protected]   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-February 20

Re: File Filter

Posted 20 February 2020 - 06:15 PM

ok and

This post has been edited by Skydiver: 20 February 2020 - 06:23 PM
Reason for edit:: Removed unnecessary quote.

Was This Post Helpful? 0
  • +
  • -

#6 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7289
  • View blog
  • Posts: 24,666
  • Joined: 05-May 12

Re: File Filter

Posted 20 February 2020 - 06:22 PM

There is no need to quote the post directly above yours.

I put in that crossposting warning so that people can be warned that you are already asking for help in another forum just like you were in your other thread. I already explained in that other thread why we warn about crossposters.

View Post[email protected], on 20 February 2020 - 06:28 PM, said:

I know pure basics cin, cout, type stuff. I don't know this advanced stuff.

I highly doubt that a teacher would give an assignment regarding abstract classes and polymorphism if it had not been covered at all. And if not covered, it should be in your textbook.
Was This Post Helpful? 1
  • +
  • -

#7 [email protected]   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 08-February 20

Re: File Filter

Posted 20 February 2020 - 06:25 PM

It's an online class. She just gives us a chapter to read and I dont understand it AT ALL

This post has been edited by Skydiver: 20 February 2020 - 06:27 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#8 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7289
  • View blog
  • Posts: 24,666
  • Joined: 05-May 12

Re: File Filter

Posted 20 February 2020 - 06:41 PM

There is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area.

My wife managed to get her Masters Degree in Nursing from a very prestigious school university in Washington, DC recently. Over the past two years, I watched her slave over bio-stats, informatics, leadership, ethics, etc. every night after a full day of work. After each reading assignment, she was is the position you were -- not understanding the assigned reading. To supplement her studies, she searched for YouTube videos to get a different explanation of the same thing. She found Wikipedia articles. She'd found Medium articles. She looked for blogposts. She contacted her classmates using IM, text messages, WhatsApp, FaceBook, etc. ask questions. When none of those worked, she used me as rubber duck by trying to explain what she thinks she understands.

It was not an easy journey. She and her batchmates struggled. It was amazing to see them gel together when they first saw each other in real life during their graduation ceremony. It's as if they had survived a war together.

I'll quote what member Salem_c wrote in the other forum with regards to your homework last week:

Quote

Well keep reading until you think you understand it.
Then keep doing exercises until you actually understand it.

It's like you're standing around in the kitchen hoping to become a master chef, just from observing others working and reading a few menus. It's not going to happen.

Real kitchen mastery comes from a long list of knife wounds, over and under cooked dishes and maybe even the occasional fire.

Programming is the same - without the physical pain and bad smells.
It's a lot of frustration, study, going back over past examples, trying different things.

Was This Post Helpful? 2
  • +
  • -

Page 1 of 1