Welcome to Assignments Writing

Your Trusted Partner in Term Paper Writing

At Assignments Writing, we’re a team of passionate educators and skilled writers committed to supporting students in their academic journey.

GU FullStack Classes Programming Code

GU FullStack Classes Programming Code

ANSWER

To finish the assignment, you must construct a stack implementation that uses vectors as the container and make numerous changes to the provided code. You should also include exception handling and show how to use STL queue methods. The updated code that satisfies these conditions is shown below:

the cpp
Copy the following code: #include <vector> #include <iostream> #include <queue> #include <stdexcept> As an exception

using the std namespace;

// Custom exceptions class using the StackException class public exception StackException: { string message;

public: }} message(msg) \} StackException(const string& msg)

const throw() const char* what() { return message.c_str(); } };

// Use vector as the container template for stackType (<class Type>).
stack type class { private: vector<Type> list; int stack top; int maxSize;

The stack type is public (int size = 100). {}    if (size <= 0)     size = 100; // Default size     maxSize = size;     stackTop = -1;     list.resize(maxSize);

In the void initializeStack(), stackTop is set to -1;

return stackTop == maxSize – 1;} bool isFullStack() const {

return stackTop == -1; bool isEmptyStack() const {

push(void, const Type& newItem) If (isFullStack()) is true, then { throw StackException(“Stack overflow: Attempt to push onto a full stack.”);
sequence[stackTop] = newItem; stackTop++;

// Using an overload to push several values onto the stack void push(const vector<Type>& items) { for (const Type& item : items) { push(item);

The void pop() function { if (isEmptyStack()) stackTop–; } throw StackException(“Stack underflow: Attempt to pop from an empty stack.”);

Type top() const { -if (isEmptyStack()) { -throw StackException(“Stack underflow: Attempt to access the top of an empty stack.”);
list[stackTop] be returned;

Const stackType<Type>& otherStack === bool operator Const {} ; stackTop!= otherStack.stackTop; if (stackTop!= otherStack.stackTop) ; return false;

for (i <= stackTop; i = 0; i++) It is as follows: { if (list[i]!= otherStack.list[i]) return false; }

come back true; } };

stackType<int> stack1(50); stackType<int> stack2(50); int main() {

stack1.push(23); stack1.push(45); stack1.push(38); stack1.initializeStack();

pile2 = pile 1;

In the event where stack1 == stack2, the code would output “stack1 and stack2 are identical” \\ endl; if not, it would output “stack1 and stack2 are not identical” \\ endl;

stack2.push(32); stack2.pop();

after pop and push operations on stack2 ****, cout \\ “****” \\ endl;

In the event where stack1 == stack2, the code would output “stack1 and stack2 are identical” \\ endl; if not, it would output “stack1 and stack2 are not identical” \\ endl;

pull2.stack(11);

after another push operation on stack2 ****, cout \\ “****” \\ endl;

In the event where stack1 == stack2, the code would output “stack1 and stack2 are identical” \\ endl; if not, it would output “stack1 and stack2 are not identical” \\ endl;

// Using stack type classes to illustrate how to utilize an STL queue queue queue<stackType<int>> stackQueue;

Push Queue stackQueue(stack1); Push Queue(stack2);

“**** Using STL queue methods ****” \\ cout \\ endl;

stackType<int> while (!stackQueue.empty()) {} the currentStack is equal to stackQueue.front(); stackQueue.pop();

if (!currentStack.isEmptyStack()) { cout \\ currentStack.top() \\ endl; cout \\ “Front of the queue: “;
alternatively The output is cout \\ “Empty stack” \\ endl;

0 is returned;
Inside this code

The stack items are now stored in a vector<Type> thanks to modifications made to the stackType class.
Stack underflow (popping from an empty stack), stack overflow (pushing onto a full stack), and accessing the top of an empty stack now have exception handling.
You can now push several values into the stack by using the overloaded push function, which now accepts a vector of items.
The code shows how to store stackType objects in an STL queue and retrieve and remove elements from the queue using the front() and pop() functions.

GU FullStack Classes Programming Code

QUESTION

Description

Use the stackADT class and stackType classes given to you in Ch. 18 and code supplied here to complete this assignment.

#include <iostream>

#include “myStack.h”

using namespace std;

int main()

{

stackType<int> stack1(50);

stackType<int> stack2(50);

stack1.initializeStack();

stack1.push(23);

stack1.push(45);

stack1.push(38);

stack2 = stack1;

if (stack1 == stack2)

cout << “stack1 and stack2 are identical” << endl;

else

cout << “stack1 and stack2 are not identical” << endl;

stack2.pop();

stack2.push(32);

cout << “**** After pop and push operations on stack2 ****” << endl;

if (stack1 == stack2)

cout << “stack1 and stack2 are identical” << endl;

else

cout << “stack1 and stack2 are not identical” << endl;

stack2.push(11);

cout << “**** After another push operation on stack2 ****” << endl;

if (stack1 == stack2)

cout << “stack1 and stack2 are identical” << endl;

else

cout << “stack1 and stack2 are not identical” << endl;

return 0;

}

Modify the stack implementation such that it uses a vectors as the container instead of an array.

Overload the pure virtual function push such that it takes a vector as an argument which pushes multiple values onto the stack.

Throw exceptions when:

An attempt is made to pop from an empty stack (display message)

An attempt is made to push onto a full stack (display message)

top() is called on an empty stack (display message).

A negative or zero value for stack size is passed to the constructor (In this case, when handling the error, automatically recall the constructor with a value of 100).

Using the STL queue container, add multiple stackType classes to a queue. Demonstrate an ability to use STL queue methods such as front() and pop().

ASSIGNMENT

Please pay careful attention to all assignment requirements. You are graded on your ability to implement each requirement.

In Week 8 we be modifying code given to you in Chapter 18 of the book and testing your ability to use the classes as intended.

See the assignment requirements for required modifications to the classes given.

The Stack classes given to you in Chapter 18 are using an array as the data structure to contain the data in the stack.      Your job is to modify this code so that a vector is used to contain the data instead.

i.e.

Replace this

Type *list;

with this

vector<Type> list;

Then modify the rest of the code to work with that vector syntax instead of the array pointer syntax.

You will also be adding exception handling for four scenarios.

Finally, be sure to see the section on testing the STL queue class as part of your main program. Use your stack Classes to add to a queue and demonstrate some common STL queue methods.

Place Your Order Here

Our Service Charter


1. Professional & Expert Writers: We only hire the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of master’s and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. We are known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: We have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

Format & Features

Our Advantages

How It Works

1. Fill Order Form
2. Make payment
3. Writing process
4. Download paper

Fill in the order form and submit all your files, including instructions, rubrics, and other information given to you by your instructor.

Once you complete filling the forms, complete your payment. We will get the order and assign it to a writer.

When your order is completed, it’s assigned to an editor for approval. The editor approves the order.

Once approved, we will upload the order to your account for you to download.  You can rate your writer or give your customer review.

What Clients Said

{

I am very satisfied! thank you for the quick turnaround. I am very satisfied! thank you for the quick turnaround.I am very satisfied! thank you for the quick turnaround.

5
Mercy M
{

I am very satisfied! thank you for the quick turnaround. I am very satisfied! thank you for the quick turnaround.I am very satisfied! thank you for the quick turnaround.

5
Jane L
{

I am very satisfied! thank you for the quick turnaround. I am very satisfied! thank you for the quick turnaround.I am very satisfied! thank you for the quick turnaround.

4.5
Rayan M

LET US DELIVER YOUR ACADEMIC PAPER ON TIME!

We are a freelance academic writing company geared towards provision of high quality academic papers to students worldwide.

Open chat
1
Scan the code
Hello
Can we help you?