Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DOne in C++ I need the corresponding .cpp files created for the given .h files. This is a program that will be put together to

DOne in C++

I need the corresponding .cpp files created for the given .h files. This is a program that will be put together to form a simple ,math game. This file doesnt have a main function yet as I am currently writting the main function. I just need the .cpp files to makes these .h files work. I need these classes to be able to work so that I may put them into my main function.

image text in transcribed

image text in transcribed

///copy and paste///

#ifndef Addition_h

#define Addition_h

#include

#include

using namespace std;

class Addition

{

//Overload the stream insertion and extraction operators

friend ostream& operator

public:

Addition();

//default constructor

//Postcondition: theAnswer=0; userResponse=0;

//invokes randomize();

void randomize();

//Function to generate two random numbers between 1 and 10.

//Postcondition: num1 and num2 are equal to between 1 and 10;

//and theAnswer = num1 + num2;

bool checkAnswer();

//Function to check userAnswer with problem answer (theAnswer)

//Postcondition: if theAnswer==userResponse appropriate feedback is displayed

// returns true if user answer is correct or returns false if user answer is incorrect;

void validate(string str1);

//Function to validate user response

//Postcondition: function accepts a string, validates it to be an int;

private:

int num1;//variable to store one of the operands

int num2;//variable to store one of the operands

int theAnswer;//variable to store the answer to the problem

int userResponse;//variable to store the user response to the problem in int format

};

#endif

///Copy and paste second file///

#ifndef Multiplication_h #define Multiplication_h

#include #include using namespace std;

class Multiplication {

//Overload the stream insertion and extraction operators friend ostream& operator

void randomize(); //Function to generate two random numbers between 1 and 10. //Postcondition: num1 and num2 are equal to between 1 and 10; //and theAnswer = num1 * num2;

bool checkAnswer(); //Function to check userAnswer with problem answer (theAnswer) //Postcondition: if theAnswer==userResponse appropriate feedback is displayed // returns true if user answer is correct or returns false if user answer is incorrect;

void validate(string str1); //Function to validate user response //Postcondition: function accepts a string, validates it to be an int;

private: int num1;//variable to store one of the operands int num2;//variable to store one of the operands int theAnswer;//variable to store the answer to the problem int userResponse;//variable to store the user response to the problem in int format }; #endif

Additonal information on assignment :

Your task is to develop a program that will teach youngsters the basic math facts of addition, subtraction, multiplication and division. The program generates random math problems for students to answer. Students get a small reward for correct answers and suffer a small penalty for incorrect ones. User statistics need to be recorded in a text file so that they may loaded back into the program when the student returns to play the game again. In addition, the youngster should be allowed to see how (s)he is doing at any time while (s)he is playing the game. One of the MAJOR objectives of this assessment is for you to demonstrate your ability to use classes.

The math problems generated must meet the following requirements:

Each class must have its own default constructor

Each class must generate and display a math problem

Each class must overload the

Each class must be able to check if the answer to the problem provided by the player is right or wrong

Each class must validate the user entry to ensure it is in fact an integer, dont let your program crash as this will cost a substantial loss of points!

You must use a class for each of the four problem types. Specifically, you must have:

h and corresponding Addition.cpp

h and corresponding Subtraction.cpp

h and corresponding Multiplication.cpp

h and corresponding Division.cpp

You must demonstrate use of classes, this means you:

Must have a separate .h file for each class prototype

Must have a separate .cpp file for each class prototype

You must use the included .h files, including the Game.h. You may not add or delete ANYTHING from the .h files

#include

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions