Lab 4 - Stack Operations

  1. Open your homework 3 in IntelliJ (or other IDE, so you can edit and test it). Today, running tests on your computer is important.
  2. If you do not have the latest state of the program on the bitbucket (or github), create a "Before lab" commit at the beginning of the lab and upload (push) it. If necessary, see the materials of the first lab. The testfile DoubleStackTest.java must be included in the version control.
  3. The teacher will assign you a partner for this lab.
  4. Explain to your partner how the interpret method works. Show that all the tests pass on your computer (if necessary, check the materials of the first lab), that the work was submitted by the deadline and the teacher's comments (must contain "ok"). The partner does the same. Compare the solutions and decide which solution to use as the basis for the ongoing work.
  5. Divide the roles: developer and tester. One partner ("developer") is responsible for the file DoubleStack.java, the other partner ("tester") is responsible for the file DoubleStackTest.java.
  6. Development: complete the interpret method so that it accepts additional stack operations at the input, which have the following meaning (English explanation):
      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, raising the third to be the first: 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)
      Examples:
              "2. 5. SWAP -" must result in 3.
              "3. DUP *" must give 9.
              "2. 5. 9. ROT - -" must give -2.
              "-3. -5. -7. ROT - SWAP DUP * +" must give 21.
         Implement changes to the interpret method. Be sure to try all the previous examples.
  7. Testing: Write junit4 tests for all examples in the previous section (complete DoubleStackTest.java based on the examples there). Add methods to check the stack underflow (DUP requires one, SWAP requires two, and ROT requires three elements).
  8. Share your result with the partner and test the new solution in both computers.
  9. Make a new commit  "Developer: name, Tester: name" and upload it to bitbucket (or github), the partner will do the same with their code, both partners must have the new versions of both files.
  10. Show the commit, the tests and running examples to the teacher. You can also run tests from the command line if there is a problem with the IDE.
  11. The teacher will discuss and ask questions about your work.
  12. The teacher inputs grades to SIS.

Jaanus Pöial