Help me confirm this program class structure

Started by
3 comments, last by Steedie 16 years, 9 months ago
Hey guys Just helping my friend with some of their early Com Sci coursework, trouble is, it's been along time since I did any design documents myself Basically the question I'm helping him with is as follows "In this piece of software, there are various types of people - factory staff, managers, board members (owner/chairman etc) It is possible for a person to have multiple roles, such as factory worker-managers. Write basic C++ class declarations for the classes you would use to model this, giving examples of fields and accessors you would expect to see in each of the classes" Now the class structure is pretty simple, he knows how to draw a class diagram once the relationships have been decided so I'm just doing the classes which I feel would be linked as so:

//========================================
//Base class
class cPerson
{
};
//========================================

//========================================
class cFactoryWorker: public cPerson
{
};
//========================================

//========================================
class cManager : public cPerson
{
};
//========================================

//========================================
class cBoard : public cPerson
{
};
//========================================


Which is simple enough, trouble is, I dont really understand what sort of accessors and fields its asking for, as its not a working program as such and just for show, I cant get my head around it What do you guys reckon? Any help would be appreciated, burnt myself out doing my particle system so this is harder than it should be lol
Advertisement
Quote:
"In this piece of software, there are various types of people - factory staff, managers, board members (owner/chairman etc)
It is possible for a person to have multiple roles, such as factory worker-managers.

Write basic C++ class declarations for the classes you would use to model this,
giving examples of fields and accessors you would expect to see in each of the classes"

Given that this is homework, even if it isn't yours, I can't provide you a solution. The "solution" they want is practically incorrect anyway; this is a very typical situation used to teach inheritance to unsuspecting CS students. Inheritance is probably a very poor solution to this problem from a real-world perspective. Pointless academic.

Anyway, they probably want you to support "multiple roles" via multiple inheritance. As far as accessors go, the best I can offer you is to consider at least one defining property of each role, and perhaps one defining action, and write prototypes for those methods (for example, you might have Manager::GetPointyHairHeight() and/or Manager::DenySoftwareRequisition()).
Yeah that's no problem, wasnt expecting a concrete solution given the circumstances

Was just hoping someone could point me in the right direction or give an indication whether or not the class structure is ok for the problem
Quote:Original post by jpetrie
(for example, you might have Manager::GetPointyHairHeight()


[lol]

OP:
This being homework, I won't say anything specific. But keep in mind what JPetrie said about multiple inheritance, and read this.
That links great, thanks :)

This topic is closed to new replies.

Advertisement