In this lab assignment you will learn about:
equals and hashCodeExamine the classes below and consider what functionality they have in common. Come up with an idea for a program that could do something useful with a collection of objects like these.
Create at least one interface to provide the functionality that your program will need to work with all three given classes. Modify each of the classes as necessary to implement your interfaces consistently.
Include the modified classes in your lab package to submit with the rest of your work in this assignment.
Write a prototype of your "useful" program in a main method class named Lab2Task1.
Keep it simple! For example, it's okay to use pre-determined data so that you don't have to deal with real user input. Just make sure that your program demonstrates the use of your interfaces and polymorphism techniques in a way that could work with all of the classes in this task and any future implementations of your interfaces!
Create the class Rational as described by API documentation given below.
Make sure that you read and understand the API documentation for the BigInteger and BigDecimal classes; the implementation of Rational should mostly rely on using the methods provided by these other classes!
Rational instances to get a precise answer for a calculation that would not be accurate using floating-point math.Completing all tasks in this lab should result in at least 8 separate Java files within a single package named like LastnameFirstname_lab2. Compress the package directory into a ZIP archive and upload it to the D2L assignment.
The marks for this lab are heavily weighted towards good coding practice and style. Pay attention to your code formatting, make sure you have documented all public members using JavaDoc, and include basic unit tests for all functions.
NOTE: This assignment is to be done individually. You can help one another with problems and questions, but in the end everyone must do their own work.
| Criteria | Marks |
|---|---|
| Programs compile and run without error | 2 |
| Good coding style | 2 |
| Task requirements met or exceeded | 2 |
| Total | 6 |