Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

C++ approach


  • Please log in to reply

#1
Satt

Satt

    New Member

  • Member
  • Pip
  • 1 posts
Hiya,

I'm trying to design a code using class methods and functions

In this question you are asked to write a console application to test a class which has been supplied by the course team. The library TMAs2005.lib contains the definition of a class Q4Queue. This class is intended to simulate a queueing system which works as follows.
Customers join a single queue to be served at a counter. There are two counters, the first of which is always open. Counter 2 is opened if the number of customers waiting in the queue is four and another customer arrives. When one customer departs from a counter, the customer at the head of the queue (if any) leaves the queue and goes to the empty counter. However, if the queue drops back to no waiting customers and a customer departs from Counter 2 then this counter will close again.
A typical dialogue from your program might include something like that shown below. The user’s choice of event — ‘A’, ‘1’ or ‘2’ — is shown in this output at the end of each prompt. Note how the prompt does not list option 2 when Counter 2 is not busy. Likewise option 1 would not be listed whenever Counter 1 is not busy. The opening and closing of Counter 2 is not explicitly mentioned in the dialogue.
...
Queue Length = 3
Counter 1 busy
Counter 2 closed
Select next event. . .
A = Arrival of customer
1 = Customer departs from Counter 1
A
Queue Length = 4
Counter 1 busy
Counter 2 closed
Select next event. . .
A = Arrival of customer
1 = Customer departs from Counter 1
A
Queue Length = 4
Counter 1 busy
Counter 2 busy
Select next event. . .
A = Arrival of customer
1 = Customer departs from Counter 1
2 = Customer departs from Counter 2
1
Queue Length = 3
Counter 1 busy
Counter 2 busy
Select next event. . .
A = Arrival of customer
1 = Customer departs from Counter 1
2 = Customer departs from Counter 2
...


The documentation provided by the author of the class, which gives prototypes
of the public methods with comments, is as follows. This information
should be all that you need to make use of the class.
void Initialise(void);
// Initialises
a
Q4Queue object with queue of
zero
length,
// Counter 1
not
busy and Counter 2 closed.
void Arrival(void);
// Updates the queue length and states of the
two
counters
// to simulate the arrival of a customer.
void LeaveC1(void);
// Updates the queue length and states of the
two
counters
//
to
simulate the departure of
a
customer from Counter 1.
void LeaveC2(void);
// Updates the queue length and states of the
two
counters
//
to
simulate the departure of
a
customer from Counter 2.
bool GetC1(void);
// Returns true if Counter 1 busy; false otherwise.
bool GetC2(void);
// Returns true if Counter 2 busy; false otherwise.
int GetQ(void);
// Returns the length of the queue.
Your task is to design and write a program to test the class along the lines
of the sample dialogue above. Your program should include calls to each of
the listed methods.


[SIZE=7]can some one help me understand the steps to doing this? or any other help wpuld be appriciated.
thanks
  • 0

Advertisements


#2
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 876 posts
here's an approach to the testing:
there are 3 variables to track - C1, C2, and Q size
the values to check are 'not busy'/'busy' for C1 and C2
the value to check for Q is < 4 and >= 4
since there are 2 states for each variable, 2*2*2 = 8 test cases

C1, C2, Q-size
1. C1=not busy, C2=not busy, Q-size < 4
2. C1=not busy, C2=busy, Q-size < 4
3. C1=busy, C2=not busy, Q-size < 4
4. C1=busy, C2=busy, Q-size < 4
5. C1=not busy, C2=not busy, Q-size>= 4
6. C1=not busy, C2=busy, Q-size >= 4
7. C1=busy, C2=not busy, Q-size >= 4
8. C1=busy, C2=busy, Q-size>= 4

write a function for each test case
note: the class functions will be tested by using them in the 8 test cases
  • 0

#3
boob

boob

    Member

  • Member
  • PipPip
  • 74 posts
Sorry, wrong post. I appologize.

Edited by boob, 01 June 2005 - 03:09 PM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP