Create an abstract class to be used as a base class


Problem

Design a bag that will do the following:

Accept a student's name (string) and maintains an array of test scores. Methods are,

Add which adds a score at the first available position. That is the position immediately following the last added score. If the array is empty, you add at the first position. If the array is full, then you cannot add and must indicate that. The function Add is a Boolean function that returns true when an item is added, otherwise it returns false.

Remove which removes the last score; scores in the middle or front, cannot be removed. If the array is empty then you cannot remove and must indicate that. The function Remove is a Boolean function that returns true when an item is removed, otherwise it returns false.

Clear which clears the array of all the scores, but before you do that, you must call the private function print, which will print the name and data in reverse order, that is, the last score in the array will be printed first and so on.

Requirements:

• class templates are used to accommodate different types.

• create an abstract class to be used as a base class with all its methods being pure abstract methods.

• create a subclass that contains the class declaration and interface for the class's methods.

• define a default constructor that will ask for a student name to be entered from the keyboard and stores it. It also initializes a counter that keeps track of the number of scores in the array and is maintained when you add, remove, or clear.

• define a null destructor.

• The maximum number of test scores is 5 and is stored in the class data as a static constant.

• The test scores may be integers, floats or doubles.

• Two private methods are defined to determine if the array isFull or isEmpty.

Client File

#include
#include
#include
#include "proj1.h"

using namespace std;

int main()
{ Student stud1; // a student
char choice, answer; // handles input from menu and controls loop
int score; // the iten to be added to the end of the array
do{
system("CLS"); // clears the screen
cout < cout << setw(15)<< " "<< "(1)- (A)ddnn";
cout << setw(15)<< " "<< "(2)- (R)emove nn";
cout << setw(15)<< " "<< "(3)- (C)learnnn";
cout << setw(35)<< "Enter Choice ";cin >> choice;
choice = toupper(choice);
switch (choice)
{ case '1':
case 'A':
cout << "nAdd what Score "; cin >> score;
if (stud1.add(score)) // call to the add method
cout << score << "nnAddednn";
break;
case '2':
case 'R':
if(stud1.remove()) // call to the remove method
cout << "nnRemovednn";
break;
case '3':
case 'C':
stud1.clear(); // call to the clear method
break;
}
cout << "another Operation "; cin >> answer; answer = toupper(answer);
} while (answer == 'Y');

return 0;
}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Create an abstract class to be used as a base class
Reference No:- TGS03255400

Expected delivery within 24 Hours