Practice with interfaces and implementing them.
OnToInterfaces project inside Eclipse. LinearCharge class that implements the Charge interface. ChargeMain that adds some LinearCharge instances to the Space.
Board Game: Begin the board game exercise described in Project 9.2 in Big Java (p. 416). Decide what methods your Game interface should have. Add these methods signatures to the Game interface provided in the boardGames package—remember, methods in interfaces do not have bodies. Write javadoc comments for your methods.
Despite what the last paragraph says in the text, you do not have to provide implementations of your interface yet. However, you should be prepared to describe your interface design to the class in our next meeting. Don’t feel like you have to get this design perfect; we’ll refine the design together in class.
BigRational: This exercise is about writing code to meet a specification. The specification is given by a provided interface. This part of the homework is due with Homework 18, but you’ll have some additional work for that homework assignment, so be sure to make a good start on this before our next class session.
Complete the TODO items in bigRational's BigRational class, in the order that they are numbered.
BigInteger class, which we’ve discussed before. Do you recall what its use is? Why not just use ints? Comparable interface and figure out what it is all about. What method(s) must a class implement if it implements Comparable? BigInteger class should reveal a method that will save you some time here. BigRational is an immutable class. Each math method should return a brand new object, leaving the operands untouched. equals() and toString() methods. Your implementation of toString() should be simple—just display in the form a/b—but be sure to display the reduced form of the fraction. Examples:
BasicBigRationalTest and LargeBigRationalTest. They are commented. Be sure to uncomment them by highlighting the code and pressing the Ctrl + / keys together. You can run both by right-clicking the bigRational package and choosing Run As → JUnit test.
throw new ArithmeticException("Divide by zero");
Remember, in all your code:
Here is the grading rubric for this assignment.
Turn in your programming work by committing it to your SVN repository.