Category : Recently Uploaded Files
Archive   : HEADZIP.EXE
Filename : PKGLOT.CPP
// IMPLEMENTATION FILE (pkglot.cpp)
// This module exports an ADT for a parking lot with two alleys
//----------------------------------------------------------------------
#include "pkglot.h"
#include "bool.h"
#include
// Private members of class:
// IntStack alleyA;
// IntStack alleyB;
// int ticket;
//
// CLASSINV: alleyA contains ticket numbers in LIFO order
// && alleyB is empty
PkgLotType::PkgLotType()
//..................................................................
// Constructor
// POST: alleyA and alleyB are empty (by implicit calls to their
// class constructors)
// && ticket == 0
//..................................................................
{
ticket = 0;
}
void PkgLotType::Park()
//..................................................................
// POST: (Alley A full) -->
// Error message displayed
// && ticket == ticket
// && (NOT Alley A full) -->
// ticket == ticket
// && Value of ticket displayed to user
// && ticket pushed onto alleyA stack
//..................................................................
{
if (alleyA.IsFull())
cout << "PARKING LOT FULL\n";
else {
ticket++;
cout << "Ticket no. = " << ticket << '\n';
alleyA.Push(ticket);
}
}
void PkgLotType::Retrieve( /* in */ int ticketStub )
//..................................................................
// PRE: Assigned(ticketStub)
// POST: Top of alleyA popped and pushed onto alleyB until
// ticketStub found or alleyA is empty
// && Error message displayed if ticketStub was not in alleyA
// && All tickets transferred back to alleyA from alleyB
//..................................................................
{
int topTicket;
Boolean found = FALSE;
while ( !alleyA.IsEmpty() && !found ) {
topTicket = alleyA.Top();
alleyA.Pop();
if (topTicket == ticketStub)
found = TRUE;
else
alleyB.Push(topTicket);
}
if ( !found )
cout << "CAR NOT PARKED IN MY LOT\n";
while ( !alleyB.IsEmpty() ) {
alleyA.Push(alleyB.Top());
alleyB.Pop();
}
}
void PkgLotType::Display()
//..................................................................
// POST: Contents of alleyA have been output in
// order from top to bottom
//..................................................................
{
IntStack tempStk = alleyA; // Copy contents of alleyA into
// temporary stack we can destroy
cout << "Alley A: ";
while ( !tempStk.IsEmpty() ) {
cout << setw(4) << tempStk.Top();
tempStk.Pop();
}
cout << '\n';
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/