Link to home
Start Free TrialLog in
Avatar of blackbeauty
blackbeauty

asked on

Implementing abstract data types

Hi,

I am trying to figure out how to do this problem and I don't have the faintest idea what to do. I need a few hints or advice on how to implement this reservation system. It suppose to use some sort of array system and if there is an easier way to handle this ... that will be great!

************************************************************
Implement the following abstract datatype reservation system (RS) that provides
the following 7 operations.

create: --> RS
Sem.: starts the reservation system

create-new-event: RSxEVNRxNAT -> RS
Sem.: creates a new event with NAT seats with a given event-number

cancel-event: RSxEVNR -> RS
Sem.: cancels the event with the given number

reserve-seat: RSxEVNRxSSN -> RS
Sem.: reserves a seat for a person with a given ssn for a given event

remove-per-res: RSxSSN -> RS
Sem.: removes the all reservation of a given person

get-ev-res: RSxEVNR -> set-of(SSN)
Sem.: gives the set reservations for a given event,

get-pers-res: RSxSSN -> set-of(EVNR)
Sem.: gives the set of events, a person has reservations for.

get-events: RS -> set-of(EVNR)
Sem.: returns the set of the currently defined events

In the above, the following types have the following meaning:

EVNR are numbers between 1 and 999999999 used to identify events; eventnumbers
are not necessarily consecutive.

NAT represents a positive integer between 1 and 1000 that is used to specify
the number of available seats for the event.

SSN represents social security numbers, which are used to identify persons that
made reservations for a particular event; ssn have to be numbers between
100000000 and 999999999.

ASKER CERTIFIED SOLUTION
Avatar of yonat
yonat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of blackbeauty
blackbeauty

ASKER

This is a nice answer to my questions but I am not understanding the 'virutal' and 'set.' I am still a beginner of data structures but I need explanation of 'virtal set.' I don't think I am that far ahead in C++.  And #include<set> and #include<map>...are those in C compiler library? What if I created some datas to go with this program such as:
create:
create-new-event:  10001  200
create-new-event:   9999  10001
create-new-event:     23  100
create-new-event:     22  150
create-new-event:     33  20
cancel-event:         23
cancel-event:         16
create-new-event:     44  10
create-new-event:     55  5
reserve-seat:       8888  555555555
reserve-seat:          1  6666666666
reserve-seat:         55  123400000
reserve-seat:         55  223400000
reserve-seat:         55  323400000
reserve-seat:          1  123456780
reserve-seat:         55  423400000
reserve-seat:         55  223400000
reserve-seat:         11  223400000
reserve-seat:         55  523400000
reserve-seat:         55  100000004
reserve-seat:         55  100000002
reserve-seat:         11  200000001
reserve-seat:         11  200000002
reserve-seat:         11  200000003
reserve-seat:         11  200000004
reserve-seat:          1  123400000
reserve-seat:          1  123456781
reserve-seat:         22  123456789
get-pers-res:             123400000
get-pers-res:             223400000
remove-per-res:           523400000
remove-per-res:           123400000
remove-per-res:           200000005
cancel-event:          1
get-pers-res:             123400000
get-pers-res:             200000001
get-ev-res:           11
get-ev-res:           55
get-events:
get-pers-res:         11
get-pers-res:         33

Is there a simpler way to this implementing using some sort of linked arrays or the polynomial system?  
<set> and <map> are standard headers. They declare the templates set and map, which are a part of the Standard Template Library (STL). STL is a part of the standard library.
It is easier to use standard ready maid containers, then to write your own, and that is why I used them.

The 'virtual' keyword has to do with inheritance and polymorphism. From your comment I gather that you haven't learned that yet, so we can ignore it: Ignore the class ReservationSystem and just use SimpleReservationSystem. Also, remover the
: public ReservationSystem
from the declaration and remove all the 'virtual's.
This will be just as good for your purposes.  have updated the web page to reflect this.

About the data: Are you sure that this is the way you want the ADT to be used? If so, I suggest you write a small parser the will parse the input file into calls to ReservationSystem.

Since this is getting a little long, I suggest we use e-mail for further discussion. You can mail me at yonat@usa.net .
Good job on explaining my program.