Classes, objects, data members, member functions,and header files.
Problem Specification:
Design a class that will do the following:
• Accept a department’s name in the school (a string) and maintains two arrays of employee’s data, one for the employee’s id, a string, the other for the employee’s salary, which might be integer, float or double.
• If there is room, you can add an id and a salary at the first available position. That is the position immediately following the last added employee. However; if the arrays are empty, you add at the first position. If the array is full,>span class=”s5″>>span class=”bumpedFont15″>add is a Boolean function that returns true when an item is added, otherwise it returns false.
• If there are employees, you can remove >span class=”s5″>number; you need to write a (private) search function that returns the index of the id, the arrays are thencompressed. If the array is empty, then you cannot remove and must indicate that. The function remove is a Booleanfunction that returns true when an item is removed, otherwise it returns false.
• You can also clear the arrays of all the data, but before you do that you must print the employee’s data in reverse order, that is, the last employee’s data in the array is printed first.
Requirements:
• Create a CRC card as explained in chapter 1.
• Specify each method’s purpose, describe its parameters, and write a pseudo-code version of its header as explained in chapter 1.
• Create a class diagram showing the class name, public and private members.
• You are to create a header file that contains the class declaration and interface file (implementation) for the class that will maintain objects of the class.
• You are to create a constructor that may take >span class=”s5″>an argument, and if it’s null it will ask for a department name to be entered from the keyboard and stores it. It also initializes a counter that keeps track of the number of employees in the array and is maintained when you add, remove, or clear.
• You have to define a null destructor.
• >span class=”s5″>employees is 5 and is stored in the class data as a static constant.
• >span class=”s5″>id number is a string; >span class=”s5″>s, floats or doubles.
• Two private methods must be defined to determine if the array isFull or isEmpty.
>span class=”s14″>.cpp” is >span class=”s14″>>span class=”s14″>defined in the implementation file and declared in the header file called “proj3.h”
Grading Criteria:
5 pointsGood programming practices: Proper spacing, comments, use of variables, indentations and appearance of program.
5 pointsdefault constructor is defined and performs its task.
5 pointsdestructor is defined and is null.
5 pointsCRC card is submitted correct and complete.
5 pointsa UML class diagram is submitted and is correct.
5 pointsa header file is used to define the class.
5 pointsa C++ implementation file contains member functions definitions.
10 pointsclass templates are used to accommodate different types.
5 points>span class=”s5″>ifndef is properly used.
10 pointsmethods specifications and pseudopod.
5 pointsmodules coupling and cohesiveness.
5 pointsAccessor methods are constants and parameters passed are also constants.
5 points>span class=”s5″>calls the print function, which prints the array elements, last to first before clearing the array.
20 pointsProgram solution fits specifications.
5 pointstest results for a run.
Submission Details: Hand–in
• the crc card
• Methods specifications
• Class diagram
• Source program files
• Test results.
include <iostream>
#include <iomanip>
#include <string>
#include "proj2.h"
using namespace std;
int main()
{ Department dept1("CIS"); // a department char choice, answer; // handles input from menu and controls loop bool success. do{ system("CLS"); // clears the screen cout <<setw(30)<< " Main Menu\n\n\n"; // menu of options to add/remove or clear cout << setw(15)<< " "<< "(1)- (A)dd\n\n"; // data is enterd from within Add cout << setw(15)<< " "<< "(2)- (R)emove \n\n"; // the id to remove is entered in Remove. cout << setw(15)<< " "<< "(3)- (C)lear\n\n\n"; cout << setw(35)<< "Enter Choice ";cin >> choice; choice = toupper(choice); switch (choice) { case '1': case 'A': success = dept1.add(); if (success) // call to the add method cout << "\n\nAdded\n\n"; else cout << "\n\nCould not add\n\n"; break; case '2': case 'R': success = dept1.remove(); if(sucess) // call to the remove method cout << "\n\nRemoved\n\n"; else cout <<"\n\nCould not Remove\n\n"; break; case '3': case 'C': dept1.clear(); // call to the clear method break; } cout << "another Operation "; cin >> answer; answer = toupper(answer); } while (answer == 'Y'); return 0; }