help with inheritance/class arrays

Write a tennis registration program that admits members who are either a student or a staff. Design an object-oriented program which consists of the following three classes: Member (member count), Student(name, tel_no, id, fees_owing) & Staff (name, tel_no, id, fees_owing). {member's the base class, student & staff are it's derived classes).



Your registration program should be able to perform the following tasks:

1. Display on screen “Welcome to c-Tennis register! Maximum : 10 members.”

Declare a Member array pointer of size 10.

2. Prompt user to enter the names and contact numbers of each member.

Use cin and cout commands.

3. Determine if the new member is a student or a staff. The student id must also be provided and stored if the member is a student.

Create appropriate Staff or Student objects for the Member reference pointer.

4. Registration for a staff is at a rate of RM12, while a student’s rate is RM8. They may pay any amount of fees up to their respective rates during registration. If they have paid enough, display “Thanks for paying RM12.” (or RM8 for students). If they have an outstanding payment, display “You still owe RM” followed by the remainder.

Write a function called pay_fees in Member that takes in the fees as its only parameter and performs the required task as mentioned above.

5.Once a new member has been successfully registered, display a summary of this member including his / her name, contact number, as well as any outstanding fees. If the member is a student, further display his / her student id. Do not display the contact number.

Demonstrate the use of polymorphism here. Write a display function that displays different messages according to the actual type of the member, i.e., whether the member is a student or a staff.

6. Keep count of how many members have been registered.

Use a static variable to achieve this, placing the static variable in the correct class.

7. This registration process may be repeated up until a maximum of 10 members. You may terminate program at any time if no more members are to be registered.
some nice homework you have there.
good luck with it.

if you have a question: ask
if you have a problem: describe it
Last edited on
// Test_2.5.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

class Member
{
public:
string name;
string tel_num;
//int fee_owing;

void reg(string n, string tel)
{
name = n;
tel_num = tel;
//fee_owing = fo;
}

/*void pay_fees(int a)
{
int res;
res = fee_owing - a;
if (res = 0)
{
cout << "Thanks for paying " << fee_owing << endl;
}
else if (cout << "You still owe RM " << res << endl);
}*/

virtual void Display(){}
};


class Student:public Member
{
public:
int id, pay;
//int select;
void signup()
{
cout << "Enter Name: ";
cin >> name;
cout << "Enter Contact Number: ";
cin >> tel_num;
cout << "Enter ID: ";
cin >> id;
//cout << "Out of RM" << fee_owing << " how much has been paid?";
//cin >> pay;
//pay_fees(pay);



/*cout << "Press 1 for Student Registration/Press 2 for Staff Registration" << endl;
cin >> select;
if (select ==1)
{
cout << "Enter ID: ";
cin >> id;
cout << "Out of RM" << fee_owing << " how much has been paid?";
cin >> pay;
pay_fees(pay);
cout << "Student " << name << " ID(" << id << ")" << " joins." << endl;
}
else if (select == 2)
cout << "Staff " << name << " joins" << endl;*/

}

void Display()
{
cout << "Student " << name << " ID(" << id << ")" << " joins." << endl;
}

};

class Staff:public Member
{
public:
void signup()
{
cout << "Enter Name: ";
cin >> name;
cout << "Enter Contact Number: ";
cin >> tel_num;
}

void Display()
{
cout << "Staff " << name << " joins." << endl;
}
};



int main()
{
Student c1;
Staff s1;

c1.signup();
s1.signup();

Member *mem1 = &c1;
Member *mem2 = &s1;

mem1->Display();
mem2->Display();


//Member *mem1 = &c1;




return 0;
}


That's how much i have done so far. I can't seem to integrate the payment method into the system. Like both staff and student inherits fee_owing from member how do i set fee_owing to 12 for staff and 8 for student?
Topic archived. No new replies allowed.