Question: A news organization needs a program to keep track of different kinds of concerns (e.g., investigations and ethics matters) about a prominent elected official. Every
A news organization needs a program to keep track of different kinds of concerns (e.g., investigations and ethics matters) about a prominent elected official. Every concern involves a primary person (e.g. Clifford or Pruitt). Different kinds of concerns have different descriptions (e.g., "An investigation" or "A $130000 payment"). Most kinds of concerns are not possible felonies, but a few are.
Declare and implement the classes named in the sample program below in such a way that the program compiles, executes, and produces exactly the output shown. You must not change the implementations of display or main.
#include#include using namespace std; Your declarations and implementations would go here void display(const Concern* c) { cout << c->description() << " involving " << c->person(); if (c->possibleFelony()) cout << ", possibly felonious"; cout << endl; } int main() { Concern* concerns[4]; concerns[0] = new EthicsMatter("Pruitt"); // Hush payments have a person's name and an amount of money (an int). concerns[1] = new HushPayment("Clifford", 130000); concerns[2] = new HushPayment("McDougal", 150000); concerns[3] = new Investigation("Mueller"); cout << "Here are the concerns:" << endl; for (int k = 0; k < 4; k++) display(concerns[k]); // Clean up the concerns before exiting cout << "Cleaning up:" << endl; for (int k = 0; k < 4; k++) delete concerns[k]; }
Output produced:
Here are the concerns: An ethics matter involving Pruitt A $130000 payment involving Clifford A $150000 payment involving McDougal An investigation involving Mueller, possibly felonious Cleaning up: Destroying Pruitt's ethics matter Destroying Clifford's hush payment Destroying McDougal's hush payment Destroying Mueller's investigation
Decide which function(s) should be pure virtual, which should be non-pure virtual, and which could be non-virtual. Experiment to see what output is produced if you mistakenly make a function non-virtual when it should be virtual instead.
To force you to explore the issues we want you to, we'll put some constraints on your solution:
You must not declare any struct or class other than Concern, EthicsMatter, HushPayment, and Investigation.
The Concern class must not have a default constructor. The only constructor you may declare for Concern must have exactly one parameter. That parameter must be of type string, and it must be a useful parameter.
Although the expression new HushPayment("Sajudin", 30000) is fine, the expression new Concern("Zinke") must produce a compilation error. (A client can create a particular kind of concern object, like a HushPayment object, but is not allowed to create an object that is just a plain Concern.)
Other than constructors and destructors (which can't be const), all member functions must be const member functions.
No two functions with non-empty bodies may have the same implementation, or implementations that have the same effect for a caller. For example, there's a better way to deal with the person() function than to have each kind of concern declare and identically implement a person function. (Notice that { return "An insult"; } and { return "A threat"; } do not have the same effect, but { return "An insult"; } and { string s("An in"); return s + "sult"; } have the same effect, which is to return "An insult".)
No implementation of a person() function may call any other function.
No class may have a data member whose value is identical for every object of a particular class type.
All data members must be declared private. You may declare member functions public or private. Your solution must not declare any protected members (which we're not covering in this class). Your solution must not contain the word friend.
So that everyone's solutions are more consistent, payment amounts must be of type int.
You may find the library function to_string useful:
#includeusing namespace std; string distance(int n) { if (n == 1) return "1 foot"; else return to_string(n) + " feet"; }
In a real program, you'd probably have separate Concern.h, Concern.cpp, EthicsMatter.h, EthicsMatter.cpp, etc., files. For simplicity for this problem, you'll want to just put everything in one file. What you'll turn in for this problem will be a file named concern.cpp containing the definitions and implementations of the four classes, and nothing more. (In other words, turn in only the program text that replaces Your declarations and implementations would go here.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
