Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Visual Studio MFC GUI The database code is below: WitStudent.h: #include WitPerson.h class WitStudent : public WitPerson { public: WitStudent(); WitStudent(string name, string addr,

image text in transcribed

Using Visual Studio MFC GUI

The database code is below:

WitStudent.h:

#include "WitPerson.h"

class WitStudent : public WitPerson {

public:

WitStudent();

WitStudent(string name, string addr, string wNum, string role);

~WitStudent();

double getWHours() const;

double getRate() const;

void payMe() override;

private:

double wHours;

double rate;

};

WitStudent.cpp:

#include

using namespace std;

#include "WitStudent.h"

WitStudent::WitStudent(string name, string addr, string wNum, string role) : WitPerson(name, addr, wNum, role)

{

cout

cin >> wHours;

cout

cin >> rate;

}

WitStudent::WitStudent()

{

}

WitStudent::~WitStudent()

{

}

double WitStudent::getWHours() const

{

return wHours;

}

double WitStudent::getRate() const

{

return rate;

}

void WitStudent::payMe()

{

cout

}

WitFaculty.h:

#include "WitPerson.h"

class WitFaculty : public WitPerson {

public:

WitFaculty();

WitFaculty(string name, string addr, string wNum, string role);

WitFaculty& operator=(const WitFaculty&);

~WitFaculty(void);

void payMe() override;

private:

double salary;

};

WitFaculty.cpp:

#include

using namespace std;

#include "WitFaculty.h"

WitFaculty::WitFaculty(string name, string addr, string wNum, string role) : WitPerson(name, addr, wNum, role) {

cout

cin >> salary;

}

WitFaculty::WitFaculty()

{

}

WitFaculty::~WitFaculty()

{

}

void WitFaculty::payMe()

{

cout

}

WitStaff.h:

#include "WitPerson.h"

class WitStaff : public WitPerson {

public:

WitStaff();

WitStaff(string name, string addr, string wNum, string role);

~WitStaff();

double getWHours() const;

double getRate() const;

void payMe() override;

private:

double wHours;

double rate;

};

WitStaff.cpp:

#include

using namespace std;

#include "WitStaff.h"

WitStaff::WitStaff(string name, string addr, string wNum, string role) : WitPerson(name, addr, wNum, role)

{

cout

cin >> wHours;

cout

cin >> rate;

}

WitStaff::WitStaff()

{

}

WitStaff::~WitStaff()

{

}

double WitStaff::getWHours() const

{

return wHours;

}

double WitStaff::getRate() const

{

return rate;

}

void WitStaff::payMe()

{

double pay = 0;

if (wHours > 40)

{

pay += rate * 40;

pay += rate * 1.5 * (wHours - 40);

}

cout

}

WitPerson.h:

#ifndef WITPERSON_H

#define WITPERSON_H

#include

using namespace std;

class WitPerson {

friend ostream& operator

friend istream& operator >> (istream&, WitPerson&);

friend ofstream& operator

friend ifstream& operator >> (ifstream&, WitPerson &);

public:

WitPerson();

WitPerson(string name, string addr, string wNum, string role);

WitPerson(const WitPerson &person);

WitPerson& operator=(const WitPerson&);

~WitPerson(void);

string getName(void) const { return Name; };

string getAddr(void) const { return Addr; };

string getWnum(void) const { return Wnum; };

string getCategory(void) const { return Category; };

string getRole(void) const { return Role; };

virtual void payMe(void) = 0; //A pure virtual function

private:

string Name;

string Addr;

string Wnum;

string Category;

string Role;

};

#endif

WitPerson.cpp:

#include

#include

#include

using namespace std;

#include "WitPerson.h"

//Initialization

WitPerson::WitPerson() {

WitPerson::Name = "Default";

WitPerson::Addr = "Default";

WitPerson::Wnum = "0";

WitPerson::Category = "Unknown";

WitPerson::Role = "Unknown";

}

//Constructor

WitPerson::WitPerson(string name, string addr, string wNum, string role) {

WitPerson::Name = name;

WitPerson::Addr = addr;

WitPerson::Wnum = wNum;

WitPerson::Role = role;

}

//Copy Constructor

WitPerson::WitPerson(const WitPerson &person) {

Name = person.Name;

Addr = person.Addr;

Wnum = person.Wnum;

Category = person.Category;

Role = person.Role;

}

//Destructor

WitPerson::~WitPerson(void) {

//delete this;

}

//stream insertion operator

ostream& operator

strm

strm

strm

strm

return strm;

}

//stream extraction operator

istream& operator >> (istream& in, WitPerson&c)

{

cout

in >> c.Name;

cout

in >> c.Addr;

cout

in >> c.Wnum;

cout

in >> c.Role;

return in;

}

ofstream& operator

{

ofs

return ofs;

}//end ofstream

ifstream& operator >> (ifstream& ifs, WitPerson &src)

{

string record;

while (getline(ifs, record))

{

int index = record.find('/');

src.Name = record.substr();

}

return ifs;

}//end ifstream

//initialize overloaded operator

WitPerson& WitPerson::operator=(const WitPerson &Person) {

if (this != &Person) {

Name = Person.Name;

Addr = Person.Addr;

Wnum = Person.Wnum;

Category = Person.Category;

Role = Person.Role;

}

return *this;

}

Source.cpp:

#include

#include

#include

#include

using namespace std;

#include "WitPerson.h"

#include "WitFaculty.h"

#include "WitStaff.h"

#include "WitStudent.h"

void addUser(vector &people, const string& category);

void User() { cout

int main() {

vector people;

vector dest;

//Manual

int user_choice;

int i = 0;

do {

cout

cin >> user_choice;

cin.ignore();

switch (user_choice) {

case 1:

addUser(people, "Student");

break;

case 2:

addUser(people, "Faculty");

break;

case 3:

addUser(people, "Staff");

break;

case 4:

cout

i = 0;

for (const auto& p : people) {

i++;

cout

cout getName()

cout getAddr()

cout getWnum()

cout getRole()

cout

p->payMe();

cout

}

break;

default:

cout

for (const auto& p : people) {

i++;

cout

cout getName()

cout getAddr()

cout getWnum()

cout getRole()

cout

p->payMe();

cout

}

return 0;

} //switch end

} while (people.size()

//cout

return 0;

}

void addUser(vector &people, const string& role) {

string user_info;

cout

getline(cin, user_info);

cin.ignore();

//tokenize string

string token;

size_t commaPos;

string name, addr, wnum;

int counter = 1;

user_info += ',';

while (user_info.size() != 0)

{

commaPos = user_info.find(",");

if (commaPos != string::npos)

{

token = user_info.substr(0, commaPos);

user_info = user_info.substr(commaPos + 1);

if (counter == 1)

{

name = token;

counter++;

}//end 1st nested if

else if (counter == 2)

{

addr = token;

counter++;

}//end 2nd nested if

else if (counter == 3)

{

wnum = token;

counter++;

}//end 3rd nested if

} //end whole if statement

else

{

token = user_info;

user_info = "";

}

} //end while loop

if (role == "Faculty")

people.emplace_back(new WitFaculty(name, addr, wnum, role));

if (role == "Staff")

people.emplace_back(new WitStaff(name, addr, wnum, role));

if (role == "Student")

people.emplace_back(new WitStudent(name, addr, wnum, role));

}

Project Specification Your database of WIT persons is to be integrated into a cohesive program with a coherent user interface. When you start your program, your existing file of persons is loaded, and a dialog box is presented for the user to select one of the following operations: Add a person to the database; Display the whole database, one person at a time, with the ability to pay the person; Exit the program. When any of the operations is complete, this dialog will be displayed until the user closes the program. Adding a person When this operation is selected, another dialog box will open to select the person's role of Student, Faculty, or Staff. Make sure only ONE role can be selected. This dialog box can also be used to enter the name, W#, and address fields. Displaying the list of persons When this operation is selected, the first person in the list is selected, and the dialog box associated with that person is displayed with relevant data. On this dialog box, there be 3 buttons: Pay, Next, Done Pay button: runs any calculations and displays gross pay on a pop-up window; The Next button: dismisses the dialog for the present person and moves to the next person in the list. If no more entries exist, display the starting dialog; Done button: dismisses the person dialog box and displays the starting dialog Closing the program Closing the program causes the present database to be stored, and all windows dismissed

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

Students also viewed these Databases questions