1 Replies - 1278 Views - Last Post: 30 December 2012 - 08:22 AM Rate Topic: -----

#1 andicom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 14-August 12

c++ Queue Simulator (cinema booking ticket)

Posted 29 December 2012 - 07:28 PM

Part 1 involves C++ class and its properties (inheritance, composition etc) which I have completed. I definitely can post the codes here but I think it is highly unnecessary? The question here is how to implement the "queue simulator" part of the question? I have two ideas as stated, but I am highly in doubt with that two ideas. I am hopeful for someone with experience to drop a few comments on the ideas mentioned above, or better, a different idea to tackle the question Part 2. I'm pretty new to C++, my scope of knowledge (& thus what the question requires) should be limited to beginner's

note: Do have a look and vote for reopen. I have edited in hope to make the inquires clearer.

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?

Is This A Good Question/Topic? 0
  • +

Replies To: c++ Queue Simulator (cinema booking ticket)

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 3845
  • View blog
  • Posts: 11,753
  • Joined: 25-December 09

Re: c++ Queue Simulator (cinema booking ticket)

Posted 30 December 2012 - 08:22 AM

Quote

What is the correct algorithm to tackle Part 2?


Quote

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

It may be possible for two instances of a program to access a file, but what will that gain you? Each program will try to read the file from the beginning to the end and "erasing" information in a file is not an easy task.

Quote

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.

This sounds like the best alternative.

Quote

What I don't get is, when/how to create and store the customer on that queue?

I think this is answered in your program description:

Quote

Your program may start (and loop) by asking the user to choose one of the following 3 options:

Use a loop and ask whether a customer is entering the queue or leaving the queue to counter 1 or counter 2.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1