Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this third part of the signature assignment, you will develop code for additional classes to analyze the data. Inheritance will be used to relate
In this third part of the signature assignment, you will develop code for additional classes to analyze the data. Inheritance will be used to relate the analyzer classes into a hierarchy.
Modify the Analyzer class to make it a base class by changing the analyze method to make it a pure virtual function; adding a virtual function means the class is intended to be a base class. Change the analyze method to virtual. Because Analyzer has at least one virtual function, the destructor should be marked virtual; its implementation remains the same since the class owns the integer array. Change the values and size variables from private to protected.
Create a class called DuplicateAnalyser that publicly inherits from Analyzer. This class will scan the data and determine which values appear more than once. Add a constructor that takes an integer array and its size. The constructor should call the base class constructor and pass these parameter values. Implement the analyze method to count the duplicated values; use the override keyword appropriately. Return a std::string with explanatory text and the count of duplicates. Only some values will be duplicated, and others will not exist or appear only once.
Create a second class called MissingAnalyzer that publicly inherits from Analyzer. This class will scan the data and determine which values do not appear. Add a constructor that takes an integer array and its size. The constructor should call the base class constructor and pass these parameter values. Implement the analyze method to count the missing values; use the override keyword appropriately. Return a std::string with explanatory text and the count of missing values. Only some values will be missing, and others will be duplicated or appear only once.
Create a third class called StatisticsAnalyzer, which performs the same statistical analysis of the data as the Analyzer class did in Part This includes the minimum, maximum, and mean values. Add a constructor that takes an integer array and its size. The constructor should call the base class constructor and pass these parameter values. Implement the analyze method using the code from the Analyzer class and use the override keyword appropriately.
Modify the Analyzer class to remove the implementation of the analyze method and make it a pure virtual function.
Modify the main function to create an instance from each of the StatisticsAnalyzer, DuplicateAnalyzer, and MissingAnalyzer classes. Call the analyze method for each instance and print out the returned results.
Use these function and class headers:
class Analyzer
void cloneValuesint values, int size
Analyzerint values, int size
virtual ~Analyzer
virtual std::string analyze
class StatisticsAnalyzer : public Analyzer
StatisticsAnalyzerint values, int size
std::string analyze override
class DuplicateAnalyzer : public Analyzer
DuplicateAnalyzerint values, int size
std::string analyze override
class MissingAnalyzer : public Analyzer
MissingAnalyzerint values, int size
std::string analyze override
Example output:
The minimum value is
The maximum value is
The mean value is
There were duplicated values
There were missing values
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