Lab 4 - Reverse Polish Notation

  1. Open your Homework 3 program in IntelliJ (or another IDE where it can be modified).
  2. If the latest version of your work is not on Bitbucket (or GitHub), create a commit called "Before lab" and push it. Do this before starting the lab. If necessary, review the materials from the first lab.
  3. The teacher will assign you a partner.
  4. In Moodle, open your last submission and show the submission time and the teacher’s latest comment (it must contain "ok"). NB! All automated tests must pass and all sources must be referenced.
  5. Explain the interpret method to your partner. Your partner will do the same.
  6. Divide the roles: developer and tester. One partner ("developer") is responsible for the file DoubleStack.java and the other partner ("tester") is responsible for the file DoubleStackTest.java.
  7. Development: complete the interpret method so that it accepts additional stack operations as input, which have the following meanings (see the Forth language manual). We assume that in the following descriptions the top of the stack is the rightmost element.
      SWAP swaps the top two elements on the stack: a b -- b a (check that at least two elements exist)
      ROT rotates the top three elements, moving the third element to the top: a b c -- b c a (check that at least three elements exist)
      DUP creates a copy of the top element: a -- a a (check that at least one element exists)
      DROP removes the top element: a -- (check that at least one element exists)
      Examples:
         Implement the changes to the interpret method. Be sure to try all the previous examples and include them in the tests.
  8. Testing: Write JUnit 4 tests for all examples in the previous section (complete DoubleStackTest.java based on the examples above). Add methods to check for stack underflow (DUP and DROP require one, SWAP requires two, and ROT requires three elements). Write at least five tests: one that includes all the previous examples ("positive test") and one for each operation to test the underflow situation ("negative tests").
  9. Share your result with your partner and test the new solution on both computers.
  10. Make a new commit called "Developer: name, Tester: name" and upload it to Bitbucket (or GitHub). Your partner will do the same with their code.
  11. Show the commit, the tests, and working examples to the teacher. You can also run tests from the command line if there is a problem with the IDE.
  12. The teacher assigns the grade. Then complete the Homework 3 defense in Moodle.

Jaanus Pöial