Given the following class
#include <iostream>
#include "Lab4/ResizableArray.cpp"
int main() {
ResizableArray<int> arr;
arr.put(2);
arr.put(3);
arr.put(4);
std::cout<<arr<<std::endl;
}
I would prefer that you use C++ but if you must you can use JavaLinks to an external site. but do speak with me if you need help moving to C++.
Write two wrapper classes, one for a queue and one for a stack.
How to:
In this assignment, you will create two wrapper classes, Stack and Queue, which will utilize an underlying instance of the ResizableArray class. A wrapper class is one that wraps around an instance of another class and constrict or limits how a user can access the said instance. What I would like you to do is to use the above class to write a stack and a queue object. All the storage features are already implemented, what you need to do is add to the correct index and remove from the correct index when adding and removing.
Task
Add any setters or getters you may need to finish your task
Implement the Stack class: Utilize the methods from ResizableArray to manage elements in a LIFO (Last In First Out) structure.
Implement the following methods
void push()
T pop()
T peek()
Make sure you can print the stack to the console with some other method.
You can find an example of how to in ResizableArray
Implement the Queue class: Use the methods in ResizableArray to manage elements in a FIFO (First In First Out) manner.
Implement the following methods
void enqueue()
T dequeue()
T peek()
Make sure you can print the state of the queue with another method
HINT/Video:
you don't need to write a lot of code. The idea here is to use Encapsulation to do most of the work.
The following recordings illustrate how you can build a stack and a heap using the standard vector in C++ and an array list in Java
Юлия
СибГУТИ
Все супер, Виктор пошел навстречу еще при начале работы, сдержал свое обещание что выполни...
Кирилл
Политехнический Институт
Отличный специалист очень ответственный, быстро, в течении нескольких часов сделал 5 работ...
Виктория
СибГУТИ
Работа выполнена досрочно, самый отзывчивый исполнитель и просто хороший человек.
Денис
РУТ(МИИТ)
Вячеслав настоящий эксперт в области информатики! Мало того что сделал задание по Тз, так ...