Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
100%

Write a program that reads a line of text, changes each uppercase letter to lowercase, and places each letter both in a queue and onto a stack. The program should then verify whether the line of text is a palindrome (a set of letters or numbers that is the same whether read forward or backward).

Cannot use <queue> Library, have to use queueADT class as shown in the below, "Queue Demo."

Thank you, will up vote.

#include <iostream> 
#include <cassert>
using namespace std;

template <class Type>
class queueADT
{
public:
    virtual bool isEmptyQueue() const = 0;
    virtual bool isFullQueue() const = 0;
    virtual void initializeQueue() = 0;
    virtual Type front() const = 0; //Function to return the first element of the queue.
    virtual Type back() const = 0; //Function to return the last element of the queue.
    virtual void addQueue(const Type& queueElement) = 0; //Function to add queueElement to the queue.
    virtual void deleteQueue() = 0; //Function to remove the first element of the queue.
};

template <class Type>
class queueType : public queueADT<Type>
{
private:
    int maxQueueSize; //variable to store the maximum queue size
    int count;        //variable to store the number of elements in the queue
    int queueFront;   //variable to point to the first element of the queue
    int queueRear;    //variable to point to the last element of the queue
    Type *list;       //pointer to the array that holds the queue elements 

public:
    queueType(int queueSize = 100) //Constructor
    {
        if (queueSize <= 0)
        {
            cerr << "Size of the array to hold the queue must "
                << "be positive." << endl;
            cerr << "Creating an array of size 100." << endl;

            maxQueueSize = 100;
        }
        else
            maxQueueSize = queueSize;   //set maxQueueSize to queueSize

        queueFront = 0;                 //initialize queueFront
        queueRear = maxQueueSize - 1;   //initialize queueRear
        count = 0;
        list = new Type[maxQueueSize];  //create the array to hold the queue elements
    }

    queueType(const queueType<Type>& otherQueue) //Copy constructor
    {
        maxQueueSize = otherQueue.maxQueueSize;
        queueFront = otherQueue.queueFront;
        queueRear = otherQueue.queueRear;
        count = otherQueue.count;

        list = new Type[maxQueueSize];

        //copy other queue in this queue
        for (int j = queueFront; j <= queueRear; j = (j + 1) % maxQueueSize)
            list[j] = otherQueue.list[j];
    } //end copy constructor


    ~queueType() //Destructor
    {
        delete[] list;
    }

    const queueType<Type>& operator=(const queueType<Type>& otherQueue) //Overload the assignment operator.
    {
        int j;

        if (this != &otherQueue) //avoid self-copy
        {
            maxQueueSize = otherQueue.maxQueueSize;
            queueFront = otherQueue.queueFront;
            queueRear = otherQueue.queueRear;
            count = otherQueue.count;

            delete[] list;
            list = new Type[maxQueueSize];

            //copy other queue in this queue
            if (count != 0)
                for (j = queueFront; j <= queueRear; j = (j + 1) % maxQueueSize)
                    list[j] = otherQueue.list[j];
        } //end if

        return *this;
    }


    bool isEmptyQueue() const //Function to determine whether the queue is empty.
    {
        return (count == 0);
    } //end isEmptyQueue


    bool isFullQueue() const //Function to determine whether the queue is full.
    {
        return (count == maxQueueSize);
    } //end isFullQueue

    void initializeQueue() //Function to initialize the queue to an empty state.
    {
        queueFront = 0;
        queueRear = maxQueueSize - 1;
        count = 0;
    }

    Type front() const //Function to return the first element of the queue.
    {
        assert(!isEmptyQueue());
        return list[queueFront];
    }

    Type back() const //Function to return the last element of the queue.
    {
        assert(!isEmptyQueue());
        return list[queueRear];
    } //end back

    void addQueue(const Type& newElement) //Function to add queueElement to the queue.
    {
        if (!isFullQueue())
        {
            queueRear = (queueRear + 1) % maxQueueSize; //use mod
                                                        //operator to advance queueRear  
                                                        //because the array is circular
            count++;
            list[queueRear] = newElement;
        }
        else
            cerr << "Cannot add to a full queue." << endl;
    }


    void deleteQueue()  //Function to remove the first element of the queue.
    {
        if (!isEmptyQueue())
        {
            count--;
         

Can't share the rest of the demo code because of the character limit.

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education