Bahir Dar University
Institute of Technology faculty of Computing
Department Of Information Technology (Bed)
Course Name: Data structure and algorithm
Group Member……………………………ID
1. Abriham Estifanos………………………1403995
2. Endawoke Mossie………………………1404465
3. Degitu Takele………………………………1403690
4 .Meseret Endalewu……………….1403677
5. Mahilet Abera……………………1410514
Submitted Date 4/11/2016
Submitted To Wondosen F.
Bahir Dar Ethiopia
Chiss Abay Garage is found at Bahirdar city. This garage has one
entrance and one exit gates. Its parking which used to hold the repaired
cars as a queue serves only a single car (does not allow two cars parked
parallel). The garage uses first come first served data structure principle
(FIFO) in a c++ program that stores the car information like plate number,
type of cars, owner of the car, arrival time. The program can implement
the following operations. First of all to add the car in the queue when new
car is arrived and to give service to a car. And it Display all cars in the
queue. To search the care using his plate number and display ordered
number from the first car in the list. To restructure the list. If the car
wanted urgently before served or repaired, all cars behind it will be out of
the garage then returned back to the queue as previous order(the car
behind it will be take its turn)ie. Delete operation
Code Description: Car Queue Management
System
Overview
The provided C++ code implements a car queue management system for
a garage. It utilizes a doubly linked list to represent the queue of cars and
a stack to temporarily store cars during the restructuring process. The
system provides functionalities to add cars, serve cars, display queue
information, search for cars, and prioritize specific cars for earlier
service.
Data Structures
car struct: Represents a car with attributes like plate number,
position in the queue, car type, owner name, arrival time, and
pointers to the previous and next cars in the queue.
start and tail pointers: Point to the first and last cars in the
queue, respectively.
CarStack array: Used as a stack to temporarily store cars during
the restructuring process.
Functions
addInfo(): Not implemented in the provided code.
addCar(): Adds a new car to the end of the queue, assigning a
unique position, calculating the arrival time, and updating the tail
pointer.
enqueue(): Adds a car to the queue, handling cases for an empty
queue, a queue with one car, and a queue with multiple cars.
setOrder(): Calculates and returns the next available position in
the queue.
setTime(): Not implemented in the provided code.
searchCar(): Searches for a car based on its plate number and
displays its position in the queue.
dequeue(): Removes the car at the front of the queue, updates
positions of remaining cars, and deletes the removed car.
display(): Displays information about all cars in the queue.
restructure(): Prioritizes a car by moving it to the front of the
queue. Involves reversing the queue from the target car to the end,
storing cars in the stack, and then re-enqueuing them in the correct
order.
dequeueRear(): Dequeues cars from the end of the queue and
pushes them onto the stack.
push(): Pushes a car onto the stack.
pop(): Pops a car from the stack.
arrival(): Calculates and returns the current time in a formatted
string.
Main Function
The main function provides a menu-driven interface for the user to
interact with the system. It allows users to add cars, serve cars, display
queue information, search for cars, prioritize cars, and exit the program.
Usage:
Users can interact with the program to add cars, view the queue, remove
cars, search for specific cars, and reorder the queue.