subject

Check if your stack is empty Implement: bool Stack_Int::is_empty() const; It should return true if the stack (_data vector) is empty and false otherwise. Just return the value of the vector::empty() method. It's a one-liner. Hopefully the first of countless one-liners you will write in your programming life. Your second miniquest- Check your stack's size Implement: size_t Stack_Int::size() const; It should return the size of the _data vector. Another one-liner! Just return the value of the vector::size() method.
Your third miniquest- Push Implement: void push(int val); It should insert the given value into your stack. Choose which end of the stack you're going to treat as the top of your stack. This will become important as your stack grows in size (Why? Discuss it in the forums.)
Your fourth miniquest- Top Implement: int top(bool& success) const; Note the unusual signature I've chosen for this method. What do you think is the reason for this? What problem am I trying to solve? What are the pros and cons of doing it this way as opposed to some other way? When called on a Stack_Int object it must return the value currently occupying the top of the stack, without changing the stack data in any way (hence the const qualifier in the method signature). If the stack is empty, you should return 0 and set the boolean parameter to false. Note that it's passed by reference. Otherwise, it should return the top element and set the parameterto true.
Your fifth miniquest- One kind of pop Implement: bool pop(); This method simply removes the top element off the data vector and return true. You can do this using a one-line std::vector method. If the vector is empty, you would not do that and return false.
Your sixth miniquest- Another kind of pop Implement: bool pop(int& val); This kind of pop() is virtually identical to your top() method, except that it has the side-effect ofremoving the element that is returned if the stack is not empty.
Your seventh miniquest- Stringify Implement: string to_string() const; This method must return a string representation of the stack of integers in the following exact format. As usual, I've colored in the spaces. Each gray rectangle stands for exactly one space. Stack ( elements): Elements, if listed above, are in increasing order of age. The parts in red above (also in angle brackets) must be replaced by you with the appropriate values. There is no newline afterthe last line that ends with "age." You would print a maximum of 10 elements this way. If the stack has more than 10 elements, you must print the top (most recent) 10 and then print a single line of ellipses (...) in place of all other elements.
Your eighth and final miniquest- Stack o' Strings You get to implement a whole other class: Stack_String. Copy the code for your Stack_Int class and adapt it to work with strings instead. This is an exercise in porting code which requires a level of understanding about what the code does. Your Stack_String should do everything your Stack_Int does… except, with strings.
Starter Code (using C++):
#ifndef Stacks_h #define Stacks_h #include #include class Stack_Int { private: std::vector _data; public: // No explicit constructor or destructor size_t size() const { // TODO - Your code here } bool is_empty() const { // TODO - Your code here } void push(int val) { // TODO - Your code here } int top(bool& success) const { // TODO - Your code here } bool pop() { // TODO - Your code here } bool pop(int& val) { // TODO - Your code here } std::string to_string() const { // TODO - Your code here } // Don't remove the following line friend class Tests; }; class Stack_String { // TODO - Your code here. Ask in the forums if you're stuck. }; #endif /* Stacks_h */
(to_string -> converts a bitset object to a string

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:50
You have just been hired as an information security engineer for a large, multi-international corporation. unfortunately, your company has suffered multiple security breaches that have threatened customers' trust in the fact that their confidential data and financial assets are private and secured. credit-card information was compromised by an attack that infiltrated the network through a vulnerable wireless connection within the organization. the other breach was an inside job where personal data was stolen because of weak access-control policies within the organization that allowed an unauthorized individual access to valuable data. your job is to develop a risk-management policy that addresses the two security breaches and how to mitigate these risks.requirementswrite a brief description of the case study. it requires two to three pages, based upon the apa style of writing. use transition words; a thesis statement; an introduction, body, and conclusion; and a reference page with at least two references. use a double-spaced, arial font, size 12.
Answers: 1
question
Computers and Technology, 22.06.2019 17:40
Write a modular program (no classes yet, just from what you learned last year), that allows two players to play a game of tic-tac-toe. use a two-dimensional char array with 3 rows and 3 columns as the game board. each element of the array should be initialized with an asterisk (*). the program should display the initial board configuration and then start a loop that does the following: allow player 1 to select a location on the board for an x by entering a row and column number. then redisplay the board with an x replacing the * in the chosen location. if there is no winner yet and the board is not yet full, allow player 2 to select a location on the board for an o by entering a row and column number. then redisplay the board with an o replacing the * in the chosen location. the loop should continue until a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred. player 1 wins when there are three xs in a row, a column, or a diagonal on the game board. player 2 wins when there are three ox in a row, a column, or a diagonal on the game board. a tie occurs when all of the locations on the board are full, but there is no winner. input validation: only allow legal moves to be entered. the row must be 1, 2, or 3. the column must be 1, 2 3. the (row, column) position entered must currently be empty (i.e., still have an asterisk in it).
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
For her science class, elaine is creating a presentation on weather in the united states. she wants to make the presentation beautiful and interesting by drawing simple cloud or wave shapes. which is the best way for elaine to draw these shapes?
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
You know the right answer?
Check if your stack is empty Implement: bool Stack_Int::is_empty() const; It should return true if t...
Questions
question
Chemistry, 04.11.2019 12:31
question
Mathematics, 04.11.2019 12:31
question
English, 04.11.2019 12:31
question
Social Studies, 04.11.2019 13:31
Questions on the website: 13722367