Fill in Order Details

  • Submit paper details for free using our simple order form

Make Payment Securely

  • Add funds to your account. There are no upfront payments. The writer will only be paid once you have approved your paper

Writing Process

  • The best qualified expert writer is assigned to work on your order
  • Your paper is written to standard and delivered as per your instructions

Download your paper

  • Download the completed paper from your online account or your email
  • You can request a plagiarism and quality report along with your paper

Intro C++ assignment

Create a Queue class that implements a queue abstraction. A queue is a FIFO list (First In First Out queue). A simple example is waiting in line, where the first person in the line is the first served. New arrivals are added to the back of the line, the next person served is (removed) from the front of the line. The Queue class needs to implement the following operations: adding to the queue at one end (the tail) removing from the queue at the other end (the head) printing all items the queue (from head to tail) erasing all items in the queue (leaving the queue empty). destructor to empty the queue before it’s destroyed (to release all memory) Additions and removals always occur at the opposite ends of the queue. You should create the following methods in your Queue class to implement the above operations addItem removeItem print erase Your Queue class must implement a linked list. Linked lists are implemented using individual items which contain a pointer to the next item in the list, as well as the information to be stored. Your Queue implementation uses a companion QueueItem class to represent each element in the list. A QueueItem contains character string as the data value, a unique (among all QueueItems in a Queue) integer item identifier, and a pointer to the next QueueItem in the list. The following is the definition for the QueueItem class. class QueueItem { public: QueueItem(char *pData, int id); // ctor void setNext(QueueItem *pItem); QueueItem* getNext() const; int getId() const; const char* getData() const; private: char _data[30]; // or, use a char* if you want to dynamically alloc memory const int _itemId; // unique id for item in queue QueueItem* _pNext; // next item in queue }; The QueueItem member functions are very basic, just setting or getting data members of the class. All the linked list manipulation is done by the Queue class member functions. The Queue class member functions manipulate the linked list of QueueItem’s, creating and destroying QueueItem objects as needed using the C++ new and delete operators. The Queue class member data includes a pointer to the head and and pointer to the tail of the linked list of QueueItems, and an integer item counter used to provide a unique item ID for every newly created QueueItem (incremented each time a new QueueItem is added, and passed as a parameter to the QueueItem constructor. It is never decremented). The following is a partial example of the Queue class; you will need to fill in the remaining methods. class Queue { public: Queue(); // ctor inits a new empty Queue ~Queue(); // dtor erases any remaining QueueItems void addItem(char *pData); void removeItem(); … private: QueueItem *_pHead; // always points to first QueueItem in the list QueueItem *_pTail; // always points to the last QueueItem in the list int _itemCounter; // always increasing for a unique id to assign to each new QueueItem }; The Queue class member functions should not have access to the private members of QueueItem objects. They call the public member functions of QueueItem. As an example, the outline of the Queue::addItem() member function is shown below. It must add a new QueueItem at the tail of the Queue, and update the _pTail pointer to point to it. The first item placed in the Queue becomes both the head and the tail of the list.: void Queue::addItem(char *pData) { // dynamically create and init a new QueueItem object QueueItem *pItem = new QueueItem(pData, ++_itemCounter); if (0 == _pHead) // check for empty queue _pHead = _pTail = pItem; else { // link new item onto tail of list using _pTail pointer … } } The removeItem() method removes the head QueueItem from the queue, and should release the memory using the C++ delete operator. It updates _pHead to point at the following item (if any) as the new head. If the list becomes empty, both _pHead and _pTail must be set to null (0). It does not change the value of _itemCounter (which is always incremented when a new item is added). If called on an empty Queue, it does nothing. The erase() method removes all the items in the queue and should release the memory. To implement, you could loop calling removeItem() until the queue is empty. The Queue destructor should ensure that all items are removed from the queue. The easiest way is to call the erase() method from the destructor. The user code (main) never see’s QueueItem objects, since they are used only for implementation inside of class Queue. main() has only the Queue object to work with. For example, the following code would create a queue with three elements, and then print it out: // note – you may need to change the definition of the main function to // be consistent with what your C++ compiler expects. int main() { Queue myQueue; myQueue.removeItem(); myQueue.addItem(“red”); myQueue.addItem(“green”); myQueue.addItem(“blue”); myQueue.addItem(“orange”); myQueue.print(); // print contents of queue (item ID and data) myQueue.removeItem(); … } Use separate header (.h) and source (.cpp) files for this homework QueueItem.h contains the class definition for QueueItem QueueItem.cpp contains the member function implementations for QueueItem Queue.h contains the class definition for Queue. Queue.cpp contains the member function implementations for Queue main.cpp contains the main() test function To test your Queue and QueueItem class implementations, write a main() program which does the following: Create a Queue Call Remove. Should do nothing since the Queue is empty. Add 4 elements. Print out the list, both the number and data. Remove 2 elements. Add 4 elements. Print out the list, both the number and data. Remove 4 elements Print out the list, both the number and data. Erase the queue. Add 3 elements. Print out the list, both the number and data. Erase the queue. Print out the list. Print a heading when printing the queue so each of the above print calls is obvious. Use unique data values for each of the items added to the queue.

WHAT OUR CURRENT CUSTOMERS SAY

  • Google
  • Sitejabber
  • Trustpilot
Zahraa S
Zahraa S
Absolutely spot on. I have had the best experience with Elite Academic Research and all my work have scored highly. Thank you for your professionalism and using expert writers with vast and outstanding knowledge in their fields. I highly recommend any day and time.
Stuart L
Stuart L
Thanks for keeping me sane for getting everything out of the way, I’ve been stuck working more than full time and balancing the rest but I’m glad you’ve been ensuring my school work is taken care of. I'll recommend Elite Academic Research to anyone who seeks quality academic help, thank you so much!
Mindi D
Mindi D
Brilliant writers and awesome support team. You can tell by the depth of research and the quality of work delivered that the writers care deeply about delivering that perfect grade.
Samuel Y
Samuel Y
I really appreciate the work all your amazing writers do to ensure that my papers are always delivered on time and always of the highest quality. I was at a crossroads last semester and I almost dropped out of school because of the many issues that were bombarding but I am glad a friend referred me to you guys. You came up big for me and continue to do so. I just wish I knew about your services earlier.
Cindy L
Cindy L
You can't fault the paper quality and speed of delivery. I have been using these guys for the past 3 years and I not even once have they ever failed me. They deliver properly researched papers way ahead of time. Each time I think I have had the best their professional writers surprise me with even better quality work. Elite Academic Research is a true Gem among essay writing companies.
Got an A and plagiarism percent was less than 10%! Thanks!

ORDER NOW


Consider Your Assignments Done

“All my friends and I are getting help from eliteacademicresearch. It’s every college student’s best kept secret!”

Jermaine Byrant
BSN

“I was apprehensive at first. But I must say it was a great experience and well worth the price. I got an A!”

Nicole Johnson
Finance & Economics

Our Top Experts

See Why Our Clients Hire Us Again And Again!


OVER

10.3k
Reviews

RATING
4.89/5
Average

YEARS
13
Mastery

Success Guarantee

When you order form the best, some of your greatest problems as a student are solved!

Reliable

Professional

Affordable

Quick

Using this writing service is legal and is not prohibited by any law, university or college policies. Services of Elite Academic Research are provided for research and study purposes only with the intent to help students improve their writing and academic experience. We do not condone or encourage cheating, academic dishonesty, or any form of plagiarism. Our original, plagiarism-free, zero-AI expert samples should only be used as references. It is your responsibility to cite any outside sources appropriately. This service will be useful for students looking for quick, reliable, and efficient online class-help on a variety of topics.