Difference between revisions of "CISC220 F2021 Lab3"
From class_wiki
(→Lab #3) |
(→Lab #3) |
||
Line 5: | Line 5: | ||
===1. C++ programming exercises=== | ===1. C++ programming exercises=== | ||
− | * '''(3 points)''' Drozdek programming assignment 4.10.3 (4.9.3 in 3rd edition): Implement the stack-based delimiter matching algorithm from Drozdek Section 4.1. As in the algorithm, you should read from a file and handle parentheses, square brackets, curly braces, and C++ comments (/* and */ pairs), and skip all other characters that may be mixed in. Use the [http://www.cplusplus.com/reference/stack/stack/ STL stack] class. You may do everything in main.cpp. | + | * '''(3 points)''' Drozdek programming assignment 4.10.3 (4.9.3 in 3rd edition): Implement the stack-based delimiter matching algorithm from Drozdek Section 4.1. As in the algorithm, you should read from a file (specified on the command line, so the TA can supply their own tests) and handle parentheses, square brackets, curly braces, and C++ comments (/* and */ pairs), and skip all other characters that may be mixed in. Use the [http://www.cplusplus.com/reference/stack/stack/ STL stack] class. You may do everything in main.cpp. Evaluate each LINE of the file separately and output a T or F for each line to cout that indicates no errors or an error, respectively. |
** To use the STL stack, you must have "#include <stack>" in your main.cpp. Also be aware that this class separates [http://www.cplusplus.com/reference/stack/stack/pop pop()] and [http://www.cplusplus.com/reference/stack/stack/top top()] into separate functions, so you will need to use top() to "read" what is about to be popped. | ** To use the STL stack, you must have "#include <stack>" in your main.cpp. Also be aware that this class separates [http://www.cplusplus.com/reference/stack/stack/pop pop()] and [http://www.cplusplus.com/reference/stack/stack/top top()] into separate functions, so you will need to use top() to "read" what is about to be popped. | ||
* '''(2 points)''' Modify [http://nameless.cis.udel.edu/class_data/220_f2014/code/array_queue.tar this array_queue class] to be ''circular'' as defined in Drozdek Chapter 4.2. You may refer to the code in figure 4.9, but what you submit should be based on array_queue. Also, please use variable names ''back'' for where things are enqueued and ''front'' for where they are dequeued as discussed in class. Don't change main.cpp; you should be able to run it to verify that your modified class still works. | * '''(2 points)''' Modify [http://nameless.cis.udel.edu/class_data/220_f2014/code/array_queue.tar this array_queue class] to be ''circular'' as defined in Drozdek Chapter 4.2. You may refer to the code in figure 4.9, but what you submit should be based on array_queue. Also, please use variable names ''back'' for where things are enqueued and ''front'' for where they are dequeued as discussed in class. Don't change main.cpp; you should be able to run it to verify that your modified class still works. |
Revision as of 12:21, 15 September 2021
Lab #3
The Drozdek references below are to the textbook. It shouldn't matter whether you have the 3rd or 4th edition.
1. C++ programming exercises
- (3 points) Drozdek programming assignment 4.10.3 (4.9.3 in 3rd edition): Implement the stack-based delimiter matching algorithm from Drozdek Section 4.1. As in the algorithm, you should read from a file (specified on the command line, so the TA can supply their own tests) and handle parentheses, square brackets, curly braces, and C++ comments (/* and */ pairs), and skip all other characters that may be mixed in. Use the STL stack class. You may do everything in main.cpp. Evaluate each LINE of the file separately and output a T or F for each line to cout that indicates no errors or an error, respectively.
- (2 points) Modify this array_queue class to be circular as defined in Drozdek Chapter 4.2. You may refer to the code in figure 4.9, but what you submit should be based on array_queue. Also, please use variable names back for where things are enqueued and front for where they are dequeued as discussed in class. Don't change main.cpp; you should be able to run it to verify that your modified class still works.
- If you have problems with the lines in the #ifdef LINUX sections of main.cpp, just comment out #define LINUX at the top. The only purpose of these lines is to put a delay after each queue element getting printed.
2. Submission
- Include a PDF file <Your Name>_README.pdf which contains the inputs and outputs of your delimiter matching program and several test strings being printed out for your circular array queue program.
- Sample delimiter tests: short, short with error, long, long with error
- Create a single tar/zip/rar file out of the top-level and all subdirectories. This archive file should be named <Your Last Name>_Lab3.tar (or .zip or .rar, etc.).
- Submit it in Canvas by midnight at the end of Tuesday, September 21