Due: Sun May 26 before 11:59PM
The purpose of this lab is to implement a set of immutable classes having primitive fields, and to implement a utility class that uses static and final fields. The classes include overridden versions of the equals, hashCode, compareTo, and toString methods. Fortunately, the implementation for toString methods is provided for you.
A sample JUnit tester for the Circle class is provided in this project files. The tester file includes many tests that cover almost all the class methods, still there are cases that are not covered.
You may want to write your own tests for those missed cases and the other classes in order to test your implementation. To do that, add your test methods into the class Lab3UnitTest similar to the existing methods for the Circle class.
Finally, note that passing all of the tests in this tester does not guarantee a good solution (in other words, you should think critically about your implementation for each method).
You may, and are encouraged to, work in groups of up to 2 students from the same lab section.
In this lab you will implement immutable classes that represent shapes including Circle, Rectangle, and Triangle.
In addition to a utility class, ShapeUtil, that provides methods to perform operations on the shapes.
Description and details of the classes is provided by this API.
You do not have to include javadoc comments in your implementation.
The Circle class is immutable class that contains one variable to store the radius of the circle,
and methods to get its area and circumference. The class implements Comparable interface to compare
two circles. It also overrides equals, hashCode, and toString from the Object class.
The Rectangle class is immutable class that contains two variables to store the width and
heights of the rectangle, and methods to get its area and perimeter. The class implements Comparable interface
to compare two rectangles. It also overrides equals, hashCode, and toString from the Object class.
The Triangle class is immutable class that contains three variables to store the length of the three sides of
the triangle, and methods to get its area and perimeter. The class implements Comparable interface to compare two triangles.
It also overrides equals, hashCode, and toString from the Object class.
The utility class ShapeUtil provides helper methods to create and compare basic shapes.
It also provides the ability to define new operations that were not implemented in the shape classes.
The recognized shapes by this class includes: Circle, Rectangle, and Triangle.
Note: If you cannot complete one or more of the methods, at least make sure that it returns some value of the correct type;
this will allow the tester to run, and it will make it much easier to evaluate your code.
For example, if you are having difficulty with compareTo then make sure that the method returns some integer value
(such as 0).
To submit your work, you need to transfer your
Circle.java, Rectangle.java, Triangle.java and ShapeUtil.java files to a
Prism lab computer. You can use a USB stick, a secure FTP program, or a secure copy program to do so.
Once you have transferred your files, log onto a Prism computer and follow the instructions below.
If you are
not working in a group, submit your solution using the
submit command. Remember that you first need to find your workspace directory,
then you need to find your project directory.
In your project directory, your files will be located in the directory
src/eecs2030/lab3
submit 2030 lab3 Circle.java Rectangle.java Triangle.java ShapeUtil.java
If you are working in a group, create a plain text file named group.txt. You can do this in eclipse using the menu File -> New -> File. Type your login names into the file with each login name on its own line. For example, if the students with login names
rey, and
finn, worked in a group the contents of
group.txt would be:
rey finn
Submit your solution using the
submit command. Remember that you first need to find your workspace directory, then you need to find your project directory.
In your project directory, your files will be located in the directory
src/eecs2030/lab3
submit 2030 lab3 Circle.java Rectangle.java Triangle.java ShapeUtil.java group.txt
It is possible to submit work from outside the Prism lab, but the process is not trivial; do not attempt to do so at the last minute if the process is new to you. The process for submitting from outside of the Prism lab involves the following steps:
Windows users will likely need to install additional software first. Mac users have all of the required software as part of MacOS.