I'm working on a project for class that I know very little about... Once we got to "classes" I became very confused and I'm having difficulties grasping all the concepts. There are so many classes and functions etc. that I literally have no idea where to even begin... I'm an extreme beginner so if you could give some explanation to your coding etc. I would appreciate it... The code I have thus far isnt really worth showing... its mostly just things like
1 2 3
|
class MathProblem
{
}
|
and some of the other classes/functions..but not much filled in etc..it seems like the project is basically just a way to be able to do simple math... but I'm really not good at this C++ stuff and have fallen pretty far behind now... .... Here is the assignment...
Problem:
1. Create a MathProblem class that holds fields such as
• Three integers: the first operand, the second operand and the user’s answer;
• One character field that stores an operator such as ‘+’, ‘-‘, ‘*’ or ‘/’;
• An integer field that shows if the answer is correct, such as 1 expresses correct, 0 wrong;
• A function called setProblem(…) that sets the MathProblem with 3 arguments ( 2 operands and an operator);
• A function getAnswer() shows the problem, accepts the answer and set the correctness by computing and comparing;
• A function showProblem() shows the problem;
• A function showOther() shows the user answer, the correct answer and the correctness of the user answer by computing and comparing;
• Include any functions you feel are useful and appropriate.
2. Create a new class MathProblemWithAnswer that inherits MathProblem and holds new fields
• An integer for the correct answer;
• An overridden function called setProblem(…) sets the inherited fields with 3 arguments, computes and sets the correct answer; and
• An overridden function getAnswer() shows the problem and accepts the answer and sets the correctness by comparing with the correct answer stored.
• An overridden function showOther() shows the user answer, the correct answer and the correctness of the user answer by comparing.
3. Write a main function to create one instance of MathProblem and one instance of MathProblemWithAnswer, use getAnswer() to get answers from a user, and use show…() to show the user’s answer, correct answer and its correctness.
4. Bonus: (10%) Write the two instances to a file and then read them back to show them again.
Any help/guidance/code would be appreciated.. thank you!