1) Assume that we want to build an application for special type of exams. The exam includes True/False questions. The number of questions per
1) Assume that we want to build an application for special type of exams. The exam includes True/False questions. The number of questions per exam varies from one exam to other. Given below Question class, where each True/False question has a text and a correct answer. Assume the class is implemented and ready for use: class Question { public: Question(string, bool); Question(); -Question(); void Set Text(string); string Get Text(); void SetAnswer(bool); bool GetAnswer(); private: string text; bool correctanswer; Write a new class called Exam. In this class, the exam has variable number of questions. In the Exam class, please define the following: 1. Two member variables, one called count of type int which will have number of questions in the exam, and other member variable called questions of type Question that will track the questions of the exam. Questions member variable should allow a dynamic array of questions. (5 points) 2. A constructor Exam(int num) where num is the number of questions in exam. (6 points) 3. A destructor (5 points) 4. A member function called void LoadQuestions(), this function will load the exam questions from user input. The user will be asked to insert a text and a correct answer for each exam question. (10 points) 5. A member function called Question GetQuestion(int question_index) which receives the index of the question and returns the exam Question of that index. (5 points) 6. A member function called int GetCount() which returns the number of questions in the exam. Note, make this function read only which means cannot modify Exam class objects. (5 points) Q2) Assume that the previous two classes (Question and Exam) are implemented and ready for use. Write a new class called Student Answer that will track students' answers for specific tests. The class prototype is as the following: class StudentAnswer { public: Student Answer(Exam *); -Student Answer(); void TakeExam(); float GetScore(); private: Exam* taken_exam; bool * answers; Note that the taken_exam member variable is used to track which exam is being taken. The answers member variables is used to track the student's answers of the taken_exam. Write the following functions: 1. The constructor StudentAnswer(Exam *) (6 points) 2. The member function TakeExam which will loop through exam questions one by one, and ask the student to enter answer for each one (T for true and F for false) and store student's answers inside answers member variable (array). (10 points) 3. The member function GetScore which will return the score assume the exam has been taken and answers are stored. (10 points) Write a main function that uses the Exam and StudentAnswer classes and does the following: 1. Create two exam objects, one called math with 30 question and one called OOP with 40 questions. Load questions for each one. (10 points) 2. Create one student answer SA1 for the math exam and another student answer SA2 for the OOP exam. Collect answers by calling take test for each one. Print final scores for each test. (10 points)
Step by Step Solution
3.37 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
Question 1 Code class Exam public Examint num Exam void LoadQuestions Question GetQuestionint questionindex int GetCount const private int count Question questions ExamExamint num count num questions ...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