Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

🎯 Objective

Design and implement a queue in C++ to store integer values. This project will help you understand the concept of queues, their structure, and their usage in C++.

\uD83D\uDDD2 Requirements

  1. Create a class called Queue with the following attributes:

    • int* arr

    • int front

    • int rear

    • int capacity

  2. Add the following methods to the Queue class:

    • A constructor that takes an integer capacity as a parameter and initializes the arr, front, rear, and capacity attributes.

    • A destructor that deallocates the memory of the arr attribute.

    • A method called enqueue() that takes an integer value as a parameter and adds it to the rear of the queue. If the queue is full, display an appropriate error message.

    • A method called dequeue() that removes the element at the front of the queue and returns its value. If the queue is empty, display an appropriate error message.

    • A method called isEmpty() that returns a boolean value indicating whether the queue is empty or not.

    • A method called isFull() that returns a boolean value indicating whether the queue is full or not.

    • A method called size() that returns the number of elements in the queue.

    • A method called peek() that returns the value of the element at the front of the queue without removing it. If the queue is empty, display an appropriate error message.

  3. In the main() function, demonstrate the usage of the Queue class. Create a Queue object, perform enqueue and dequeue operations, and call the isEmpty(), isFull(), size(), and peek() methods to display the queue's state.

🚚 Deliverable

Upload the following:

  1. Full source code (.cpp files or .txt files)

  2. Screenshot of the Console with the code executing

  • No labels