Details of this Paper

LAB 8a-8c: Write And Apply A Stack Template

Description

solution


Question

Question;LAB 8a: Write And Apply A Stack Template [ Stack.h, StackDriver.cpp, and Calculator8.cpp ]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 fileJust 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 mismatchesEnter filename (H, CPP, JAVA, HTML, or JS): x.cppNo mismatches found by my preprocessor in x.cppExample: file with no closing parenthesisEnter filename (H, CPP, JAVA, HTML, or JS): x.cppOpening parenthesis found in line 10 of x.cppBut no matching closing parenthesis foundExample: file with no opening square bracketEnter filename (H, CPP, JAVA, HTML, or JS): x.cppClosing square bracket found in line 10 of x.cppBut no matching opening square bracket found

 

Paper#36572 | Written in 18-Jul-2015

Price : $42
SiteLock