GMU Fall 2022 – CS 211 – Exercise 2
Objective
The purpose of this assignment is to practice enums, exceptions, and unit testing. You will implement and modify a few classes that solve a programming task, and then you will write a small tester to test your code. No tester will be provided for this assignment.
Overview
Analyze the ShapeManager class and the interface it uses, AreaCalculator.
Analyze the Shape class hierarchy, used to represent a limited set of shapes.
Analyze the enum named MeasuringUnit, used to represent the shape sides’ unit ofmeasurement (FEET, or METER).
Implement the exception classes Shape Exception, Measuring Unit Exception and Area Calculator Exception, which shall be used to signal improper values and impossibleactions relating to classes.
Write a class named E2Tester that performs unit testing for the classes.
Prepare the assignment for submission and submit it through Blackboard
Background
During use of the classes, sometimes we may accidentally try to feed bad values into a method. In these cases, the program should raise an exception. The unit tester should be able to verify that the code is properly signaling the illegal operations via exceptions.
However, unchecked exceptions are a controversial topic. The client using your Application Program Interface (API) is expected to be NASA and the Pentagon, so no exception left unchecked. In Java, your API consists of the public classes and their public members .
We will relax such requirement to checking for the following Java Unchecked Exceptions:
Null Pointer Exception (NPE)
Array Index Out of Bounds Exception (AIOBE)
Arithmetic Exception (AE)
Illegal Argument Exception (IAE)
Illegal State Exception (ISE)You will mask those unchecked exceptions within the realm of the three exceptions listed above for this exercise . Exception Masking is catching an exception and propagating a different one. Since, unchecked exceptions are not listed by the compiler, your code must be explicit in throwing this exercise’s exceptions.
page1image51282336 page1image51287328 page1image51291072 page1image51290864 page1image51286496page1image51289200
Classes
Last Completed Projects
topic title | academic level | Writer | delivered |
---|