8 points total
Turnin: You should turn in three files: ArrayExample.java, GoodArrayExample.java, and ArrayListExample.java
These questions use a hierarchy of classes of simple geometric objects. Here are the definitions:
Running Java: You can run Java on whatever machine you want. If you don't have some other machine you prefer, you can use attu (javac Test.java to compile the program, java Test to run it).
Exception in thread "main" java.lang.ArrayStoreException: Cone at ArrayExample.main(ArrayExample.java:10)Hint: look at the ArrayTest example in the lecture notes.
Next, look at the code in GoodArrayExample.java. (This is exactly the same except for the class name.) Add statements to this code as needed, so that the code compiles correctly, and runs without error.
If you want, you can add some statements to these "main" methods to get them to print something so that you know they are doing something, but you don't need to.
Example with a list of shapes with a circle, a cone, and some empty shapes Circle[radius=1.0] Cone[radius=2.0,height=3.0] Circle[radius=0.0] Cone[radius=0.0,height=0.0] Rectangle[width=0.0,height=0.0] Sphere[radius=0.0] Total number of shapes: 6 Example with a list of rectangles Rectangle[width=2.0,height=3.0] Rectangle[width=5.0,height=5.0] Total number of shapes: 2 total area of rectangles: 31.0 total perimeter of rectangles: 30.0 Example with a list of 2d shapes with a circle and a rectangle Rectangle[width=10.0,height=10.0] Circle[radius=2.0] Total number of shapes: 2 total area of flat shapes: 112.56637061435917