07 Jun LAB 8a-8c: Write And Apply A Stack Template
Question
Purpose. In this lab you will write your own stack template, using either array or linked-list implementation, per your choice.
Requirements. Rewrite lab 2’s Calculator2.cpp as Calculator8.cpp, but use your own templated stack class. Name your class Stack, and write its specification and function templates in a file named Stack.h. Use either a dynamic array or a linked list to implement the class, and be sure to include dynamic memory management. If you use a linked list, use Node as the node struct name, and include it in Stack.h, making sure to enclose it in its own #ifndef NODE / #endif container — that will prevent compiler problems when you write a queue template later.
In addition to the calculator application, and prior to developing it, write a driver program, StackDriver.cpp, to fully test your templated stack class. Refer to the lecture topic 3 notes for how to test a class, which includes ifndef, object copy, and object assignment testing. Make sure that you test every function that you write.
You decide on the “design consideration” issues that are listed in the lecture topic 8 notes. Decide on the pop, push, and peek options — you do not have to choose the same as is indicated in the notes. If you use a linked list, decide if you want a header node or not. Decide any extra functionality that you may wish to include, such as size tracking or status tracking. But do not use the Array template that you developed, and do not use any STL containers in your Stack, and do not include any cout statements in the template.
Submit the three files (2 CPPs and 1 H) to the class website for credit.
Program I/O. Same as for Calculator2.cpp.
LAB 8b: Write And Test A Queue Template [ Queue.h and QueueDriver.cpp ]
Purpose. In this lab you will write your own queue template, using either array or linked-list implementation, per your choice.
Requirements. Rewrite your own templated queue class. Name your class Queue, and write its specification and function templates in a file named Queue.h. Use either a dynamic array or a linked list to implement the class, and be sure to include dynamic memory management. If you use a linked list, use Node as the node struct name, and include it in Queue.h, making sure to enclose it in its own #ifndef NODE / #endif container, to prevent compiler issues when using your queue with other linked-list classes.
Write a driver program, QueueDriver.cpp, to fully test your templated stack class.
You decide on the “design consideration” issues that are listed in the lecture topic 8 notes. Decide on the pop, push, and peek options — you do not have to choose the same as is indicated in the notes. If you use a linked list, decide if you want a header node or not. Decide any extra functionality that you may wish to include, such as size tracking or status tracking. But do not use the Array template that you developed, and do not use any STL containers in your Queue, and do not include any cout statements in the template.
Submit the two files (1 CPP and 1 H) to the class website for credit.
Program I/O. All console I/O, in the driver program only.
LAB 8c: Use A Stack [ PreProcessor.cpp ]
Purpose. In this lab you use a stack to solve the “matching brackets” problem. Your program will read an input text file, and report the first-found container mismatches, such as unbalanced parentheses.
Requirements. Write PreProcessor.cpp, that prompts the user for an input filename, and checks it for matching container brackets. The input file should be expected to be a text file, of type H, CPP, JAVA, HTML, or JS. Check for these bracket combinations:
parentheses ( and )
curly braces { and }
square brackets [ and ]
comment offsets /* and */ — in a CPP, H, JAVA, or JS file
Just report the first found occurrence of a mismatch.
Do NOT check for angle brackets, because there can be less-than and greater-than symbols that make that hard to manage. And don’t worry about the appearance of these symbols inside static strings, like “]”. They will appear as mismatches in your program, and that’s okay — we’re not writing a compiler… yet.
Use a stack data structure as the basis of your solution, but you decide whether to use your own Stack template that you developed for lab 8a, or the STL stack.
Note that when using a string for a filename, the “open” statement in ifstream is supposed to use a C-string as a parameter, and not a C++ string. Your compiler may overlook this non-standard behavior, but your instructor will not. [ Read more… ]
Fully test. Every one of the H files you’ve created for this class should run successfully through your preprocessor, so test with those. The PreProcessor.cpp file itself should fail — test with it, too, and verify that it finds the first error where you think if should. Submit the completed CPP file to the class website for credit.
Program I/O. Input: using cin, a filename. Include the expected filename extensions in the prompt (H, CPP, JAVA, HTML, or JS) for reference only — that is, don’t validate. Output: If there are no mismatches, say so in your own words. Otherwise, output the line number of the line containing the opening bracket, say what that bracket is, and say that you cannot find the closing backet and what that bracket should be. Or, output the line number of the line containing the closing bracket for which there is no opening bracket, say what that bracket is, and say that you cannot find the opening backet and what that bracket should be.
Example (computer prompts in bold).
Example: file with no mismatches
Enter filename (H, CPP, JAVA, HTML, or JS): x.cpp
No mismatches found by my preprocessor in x.cpp
Example: file with no closing parenthesis
Enter filename (H, CPP, JAVA, HTML, or JS): x.cpp
Opening parenthesis found in line 10 of x.cpp
But no matching closing parenthesis found
Example: file with no opening square bracket
Enter filename (H, CPP, JAVA, HTML, or JS): x.cpp
Closing square bracket found in line 10 of x.cpp
But no matching opening square bracket found
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
