Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Eclipse version to use:
- =======================
- -- Use `Eclipse Luna SDK`
- When importing the prac code into the package:
- ==============================================
- -- Remember that the package structure must match what it says in the file;
- i.e., if the file says "package week4", then the file needs to be in a
- package called week4!
- -- You need to add the JUnit library to your project in order for the JUnit tests
- to work. To do this:
- - Right-click on your project
- - Select Build Path --> add libraries
- - Select JUnit
- - Click next
- - Click finish.
- How to generate Javadocs:
- =========================
- - Select the project containing your prac code
- - Click "Project" in the menu bar
- - Select "Generate Javadoc"
- - You *may* need to tell it where to find the executable that generates the javadoc.
- - Click configure
- - Navigate to Program Files, find the JDK, go to `bin`. There should be a `javadoc.exe` somewhere.
- - follow instrusctions on pop-up dialogue.
- - If you left everything as default in the pop=up, you should get a folder called `doc`
- in your project. The `doc` folder will contain a folder called `week4` or whatever else
- you called your package. Double-click on the HTML file to view the javadoc.
- How to run JUnit tests:
- =======================
- -- Select your project
- -- Go to the little green play button on the menu bar and press the downwards-pointing arrow
- next to it, then choose JUnit test. Alternatively, do Alt+Shift+X then press T
- Hints for implementing checkInv():
- ==================================
- -- The invariants are written in a comment at the top of the class.
- For ease of reference, copy them into the checkInv() method.
- -- What does the ArrayList `terms` store?
- -- Read the documentation for Term. How do you access the coefficient and exponent?
- -- For checking whether there are repeated exponents:
- - As with everything, there are multiple ways to do this. For one way,
- google the Javadoc for `Set` and see what the class does.
- Exiting debug mode:
- ===================
- -- To go back to your code from the debug view, click the `Java` button at the top right hand side,
- next to `Debug`.
- Hints for implementing the subtract method:
- ===========================================
- -- What exactly does it mean to subtract something? You can think of 3 - 5 as 3 + (-5), right?
- -- There is a method called `subtract()` in the Term class.
- -- There is also a method called `negate()` which returns the negative of a term.
- i.e., if the original term is 3x it will return a new term -3x.
- Writing JUnit tests for the Lamp class:
- =========================================
- -- This is a simple class so the tests are going to simple; don't overthink it!
- -- Basically, all you want to do is to make sure that the state of the lamp is always correct.
- -- You want to test the initial state of the lamp - what state should it be in
- when you construct it? I.e., should it be OFF, LOW, MED or HIGH?
- -- Then you want to make sure that any method that changes the state of the lamp (i.e.,
- changes whether or not it's OFF, LOW, etc.) changes the state correctly. You should
- test all possible state transitions.
- -- Remember to import the `Assert` class from JUnit.
- Miscellaneous:
- ======================
- -- Do not make any assumptions about where a bug is. For instance, if you wrote the checkInv()
- function incorrectly, then your tests will fail even if Polynomial's add() method is correct.
- If you are convinced that you tracked down the bug, make sure your checkInv() is correct!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement