Lab 3 (100 pts)
Due Monday, April 30 at 9:20am on Canvas

  • Watch the video and answer the questions on this worksheet.
  • Both partners fill in, sign and date the pair programming contract.
  • Upload the two documents along with your assignment to Canvas under Lab 3.
  • BOTH partners submit the pair programming contract and worksheet.
  • Only ONE partner submits the lab assignment.
  • BOTH partners should put their names in a comment at the top of all files that are submitted

Part 1: Implementing Your Stack and Queue (60 pts)
  • Before you begin Part 2 of this lab, make sure that you have your Stack and Queue data structures working properly.
  • Note: Your will be using the Queue class that you wrote during class time.
  • For the Queue class instructions, see Queue Lesson (Lesson 5)
  • For the Stack class instructions, see Stack Lesson (Lesson 6)
  • No credit for altering the class definition in Queue.h and Stack.h from what was provided in class.
  • Place all of your files into a single directory or project (Queue.h, Stack.h, + your commented out test files - StackTest.cpp and QueueTest.cpp).
  • Make sure to test all of your functions to ensure that they are working properly in separate test files, named QueueTest.cpp and StackTest.cpp (where you should call the functions inside of main).
  • -20 points for not testing each function fully in QueueTest.cpp and StackTest.cpp
  • Please use NULL and not nullptr

Part 2: Palindrome Tester (40 pts)

  • This is a common interview question!
  • Using a stack and a queue, determine whether a string is a palindrome.
  • Create a new text file called palindrome.txt and save it in the same directory with your other files, or in the same project.
  • Copy and paste the following contents into palindrome.txt:

A man, a plan, a canal, Panama.
Do geese see God?
Never odd. Even.
Never odd or even.
Able was I ere I saw Elba!
Was it Eliot's toilet I saw?
Race cars

  • Next, create a new C++ file called Palindrome.cpp.
  • Write a program to test each phrase in palindrome.txt to see if it is a palindrome.
  • For credit, you must use both your Queue and Stack classes in the solution to this problem.
  • Note that you must use only 1 stack and 1 queue in your solution to this problem in order to receive credit for this assignment!
  • Hint: Convert each individual char to a string before you insert it into your stack and queue.
  • Print out your results to the console, like what is shown below in the next section.
    • Indicate in parenthesis next to each phrase whether or not it is a palindrome

Your Program Should Give the Following Output:

A man, a plan, a canal, Panama. (Palindrome)
Do geese see God? (Palindrome)
Never odd. Even. (Not a Palindrome)
Never odd or even. (Palindrome)
Eye (Palindrome)
Ear (Not a Palindrome)
Able was I ere I saw Elba! (Palindrome)
Was it Eliot's toilet I saw? (Palindrome)
Race cars (Not a palindrome)

Specifications for Submission:

  • Submit your Queue.h, QueueTest.cpp, Stack.h, StackTest.cpp, and Palindrome.cpp (one partner)
  • Submit your pair programming contract and worksheet to Canvas (both partners).
  • Please do NOT submit your files as a zip or you will receive a 5 point deduction
  • No credit if you do not work with a partner on this lab.
  • 10 point deduction for not submitting pair programming contract and worksheet.