473,500 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

the last one

Data Storage
Problem Statement

In an organization there are 3 kinds of people: Staff, Students and
Research Associates. Research Associates are actually students who are
considered as staff, and are employed for specific projects.

You will have to create a (non-persistent) data storage mechanism in
your implementation, which allows the management of data associated
with all 3 kinds of people. Furthermore, there will be a standardized
access mechanism for accessing the data.

Program
#include "classes.h"

int main(){

PeopleContainer pc;

//add a student

Person *p = (Person *) new Student("FPGDST","d0253001");

p->SetName("gopu");

p->SetGender('M');

p->SetDateOfBirth("20-03-81");

pc.Add(p);

//another student

p = (Person *) new Student("FPGDST","d0253002");

p->SetName("radha");

p->SetGender('F');

p->SetDateOfBirth("18-12-81");

pc.Add(p);

//add staff

p = (Person *) new Staff("18-05-2000",'A');

p->SetName("sunita");

p->SetGender('F');

p->SetDateOfBirth("18-12-81");
pc.Add(p);

//a student

Student s1("FPGDST","d0253004");

s1.SetName("sandeep");

//make the student an RA

p = new RA(s1);

pc.Add(p);

//get all the students

PeopleContainer *ptrSC = pc.GetStudents();

PeopleIterator si = ptrSC->NewPeopleIterator();

cout<<"Output 1"<<endl;

p = si.First();

while(!si.IsOver()){

p->ShowDetails();

p = si.Next();

}

//all staff with given grade

cout<<endl<<"Output 2"<<endl;

PeopleContainer *ptrStaff = pc.GetStaffByGrade('X'); //invalid
grade

if(ptrStaff){ //check return if no staff found

PeopleIterator sti = ptrStaff->NewPeopleIterator();

p = sti.First();

do{

p->ShowDetails();

p = sti.Next();

}while(p!=NULL);

}

//remove a person

cout<<endl<<"Output 3"<<endl;

cout<<pc.Remove("sudeep")<<"-";

cout<<pc.Remove("sandeep");

return 0;

}

(Note - new-lines have been printed in main(). No output from
the
implemented classes should have a new-line)
You are required to implement the following classes

Class: Person
Methods:

Person()
Person(char*,char,char*) /*arguments will be the name, gender(`M' or
`F') and date */
SetName(char*)
SetGender(char )
SetDateOfBirth(char *)
char* GetName()
char GetGender()
ShowDetails() /* should list the name, gender and date of birth
separated by `:' and terminated by `#'*/

Class: Staff
Methods:
Staff()
Staff(char *, char) //joining date, grade will be passed
SetJoiningDate(char *)
SetGrade(char)
char GetGrade()
ShowDetails() /*should list person details (as in Person), and then
list the joining date, and grade separated by `:' (colon) and
terminated by `#' */

Class Student
Methods:
Student()
Student(char *, char*) //course and roll number
SetCourse(char *)
char* GetRollNumber()
ShowDetails() /* should list person details (as in Person) and then
list the course and the roll number separated by `:' and terminated by
`#' */

Class RA
Members:
RA(const Student &)
ShowDetails() /* should list the details of the person, staff and
student separated by `:' and teminated by a `#' - note this is
different from the previous descriptions of ShowDetails*/
Class PeopleContainer
Methods:
bool Add(obj *) /*where obj is pointer of type Person, Staff, Student
or RA - addition is at end of current list*/
int Remove(char *name) /* remove all people with given name and return
the number of people removed or 0 */
int Remove(obj *) /* remove all people with same name as the name of
the passed object and return the number of people removed or 0 */
Sort() /*sort the contents on the basis of type in the order Person,
Staff, RA, Student. Within a type, the order of insertion must be
maintained*/
ShowPeople() /*Show Details of all the people in the container*/
PeopleContainer * GetStudents() /*returns another container containing
students only - any modifications to the contents of returned
container must not affect the original container*/
PeopleContainer * GetFemales() /*returns another container containing
females only*/
PeopleContainer * GetStaffByGrade(char grade) /* return a container
that has all staff of given grade. If no grade or invalid is passed,
include all Staff and RAs*/
PeopleIterator NewPeopleIterator() /*returns an iterator associated
with the current PeopleContainer object*/

Class PeopleIterator
Methods:
Person* First() //returns the first element of the associated
container and the current now points to the first element
bool IsOver() // returns true if the iteration is over - i.e. Next()
will return NULL
Person* Next() /*if there is a next element in the container, it
becomes the current element and is returned. If there is no next
element, NULL is returned and current element remains the same*/

Restriction
It should not be possible to create an iterator except by using
PeopleContainer::NewPeopleIterator() method Additional Points
Valid grades for Staff will be `A', `B', `C' and `D' only. Research
Associate (RA) can have only one grade, which is `R'
Do not make assumptions about the maximum number of persons that may
be stored in the PeopleContainer.
For any method involving display, if associated data is not found then
the output for that field is suppressed (the other delimiters should
be displayed)
Though the test program will check only the specified methods of the
various classes, the students may have to use other methods and
members to aid them in the implementation.
While adding a Research Associate (RA) to the container, if a Student
having the same RollNumber is found, that Student should be removed
from the container. Do not worry about finding an exact match for all
the attributes.
PeopleContainer should be heterogeneous with reference semantics.
Objective
Using the concepts of Encapsulation, Access Mechanisms, Information
Hiding, Inheritance and Polymorphism
Getting familiar with the concepts of Object Oriented Design,
Container-Contained relationships and Iterators.
Concretizing theoretical concepts learnt in class, with practical
implementation in C++.

Submission Procedure
You must have a header file DataStore.h and C++ file DataStore.cpp.
No main() should be present in DataStore.cpp.
We will test your code against our own main routine similar to the one
given as the example usage, but using more comprehensive inputs, and
for testing a wide variety of functionality as is possible using your
class.

--------------------------------------------------------------------------------
Jul 22 '05 #1
8 1284
sudeep wrote:

[Yet another homework assignment]

Ok, done. Send me $50 and you'll get a license for ulimited use of the
program. For another $250, I'll also give you the source code.

Jul 22 '05 #2

Here's my address:

JKop + at + eircom + dot + net
I'll do it for you for USD 30.00

-JKop

Jul 22 '05 #3

"sudeep" <su************@yahoo.co.in> schrieb im Newsbeitrag
news:fa**************************@posting.google.c om...
...


I tried to read you post carefully, but I could not locate the question.
Although I like the area of (code) obfuscation quite much, I'm not sure if
it's useful within newsgroup postings. :-)

So, what exactly is your question?

Regards
Michael
Jul 22 '05 #4

"sudeep" <su************@yahoo.co.in> schrieb im Newsbeitrag
news:fa**************************@posting.google.c om...
[SNIP]

You are required to implement the following classes
Hmmm, what in the whole world makes you think that I'm required to implement
the following classes. I guess I must have missed something....

[SNIP]
You must have a header file DataStore.h and C++ file DataStore.cpp.
Ooops, sorry but I do not have a header file DataStore.h
No main() should be present in DataStore.cpp.
Don't worry, this is done. There is not even a DataStore.cpp present.
We will test your code against our own main routine similar to the one
given as the example usage, but using more comprehensive inputs, and
for testing a wide variety of functionality as is possible using your
class.


Hey, just go ahead and test my code. I'll be interested in the outcome ;-)

Chris
Jul 22 '05 #5
"sudeep" <su************@yahoo.co.in> wrote in message
In an organization there are 3 kinds of people: Staff, Students and
Research Associates. Research Associates are actually students who are
considered as staff, and are employed for specific projects.


Multiple inheritance might be the right thing here.

class Person; // abstract base class, no data
class Staff ; // abstract class, derives from Person, no data
class Student; // abstract class, derives from Person, no data
class ResearchAssociate; // concrete class, derives from Staff and Student,
data
class ConcreteStaff; // concrete class, derives from Staff, data
class ConcreteStudent;
Jul 22 '05 #6
JKop <NU**@NULL.NULL> wrote in message news:<Bf*******************@news.indigo.ie>...
I'll do it for you for USD 30.00


For shame! What if third world students can't afford to buy
help with their homework? You would deny them the ability to
cheat just because you are a money grubber? For shame!
Socks
Jul 22 '05 #7
On 18 Oct 2004 14:02:39 -0700, pu*********@hotmail.com wrote:
JKop <NU**@NULL.NULL> wrote in message news:<Bf*******************@news.indigo.ie>...
I'll do it for you for USD 30.00


For shame! What if third world students can't afford to buy
help with their homework? You would deny them the ability to
cheat just because you are a money grubber? For shame!
Socks


LOL! Good one.

--
Bob Hairgrove
No**********@Home.com
Jul 22 '05 #8
posted:
JKop <NU**@NULL.NULL> wrote in message
news:<Bf*******************@news.indigo.ie>...
I'll do it for you for USD 30.00


For shame! What if third world students can't afford to buy
help with their homework? You would deny them the ability to
cheat just because you are a money grubber? For shame!
Socks


Exactly correct.

I'll offer benefit in return for benefit.

Here's I'm offering programming done in return for purchasing power.

It's a very simple concept, we humans have been doing it for millenia, you
should really try it out!
-JKop
Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3571
by: SimonC | last post by:
I would like to return data from the last 2 weeks of each given month in Javascript, but in 2 formats. So, the penultimate week (Monday to Sunday) and the last week (Monday to ??) I'm not...
7
2140
by: Scott W Gifford | last post by:
Hello, I'm considering using XML to represent a stream of location information, and XPath to do queries against it. I've got most of it figured out (at least on paper), but I can't figure out...
3
2008
by: AndyBell | last post by:
Hi all! I have an Access 2000 database for the Habiat for Humanity where I work. This is the second database I have written and it gets a bit more complex each time... I have learned much and...
32
4093
by: James Curran | last post by:
I'd like to make the following proposal for a new feature for the C# language. I have no connection with the C# team at Microsoft. I'm posting it here to gather input to refine it, in an "open...
2
2917
by: rf | last post by:
Hey I need to be able to get the dates from last wednesday to the past tuesday on thursday or friday every week. How would I do that? For example: m t W TH F M T w th f I would need the...
17
2510
by: michel.ank | last post by:
Hi, I'm using the class PrintLines and my last record of page aren't with the borders. Somebody can help me? Thanks,
6
5763
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line...
2
3250
by: Kevin Burton | last post by:
I don't think I understand the last() function. I have a document that looks like: <Root> <Header>Some text</Header> <Message> <MessageID>1</MessageID> . . . . </Message>
13
14890
by: Greg | last post by:
Most suggestions on this topic recommend to use a page footer and make it visible only on the last page. My problem is that the footer is half of the height of a page which means the detail would...
23
18031
by: Florian Lindner | last post by:
Hello, can I determine somehow if the iteration on a list of values is the last iteration? Example: for i in : if last_iteration: print i*i else:
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.