Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

c++ Queue Simulator (cinema booking)

Status
Not open for further replies.

cache

Newbie level 1
Joined
Dec 30, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,298
Based on the question below, I have finished Part 1 of the Sales System. Going into Part 2, there are things that I don't really get.

Problem Statement

You are hired to develop a sales system for cinema ticket and a simulator for queuing. The business
rules are listed below:

Part 1 Sales System (13 marks):
All tickets are priced at RM10 per person.
There are 3 types of customers:
Non-member: No annual fee, do not enjoy any discount or benefit.
Gold member: RM10 annual fee, enjoy a 10% discount for every ticket purchased.
Platinum member: RM50 annual fee, enjoy a 20% discount for every ticket purchased and
get a free ticket for every 5 tickets purchased.

Part 2 Queue Simulator (2 marks)
There are 2 sale counters serving one queue. Your program may start (and loop) by asking the
user to choose one of the following 3 options:
A customer joins the queue.
Counter 1 takes the next customer.
Counter 2 takes the next customer.

For every option selected, your simulator should list following:
The queue.
The customers already served by the counters.
The customers currently being served by the counters.


My question:
What is the correct algorithm to tackle Part 2?

My ideas :

1. First is, Save all records into a file so that two instances of the program can access the file. Is this possible?

2. Second, create an "in-program" queue - where only an instance of the program is run and queue could be a simple array or LinkList. What I don't get is, when/how to create and store the customer on that queue? can we have somewhere in the program, an interrupt mechanism to prompt for adding a customer into queue while it is running on different sections of the program?

is there any other method/algorithm?
 

An event driver system might be a good solution. Like you create a queue first and when a new customer arrives you insert a new event for a new customer in a random number of time and loop the events. Search for the word 'event driven'.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top