11A
The GeometricShape interface will have one method, area, which takes no parameters and returns a double.
You are provided with three classes: Parallelogram, Circle, and RightTriangle. Modify the classes so that they implement the GeometricShape interface. Supply the appropriate method for each class.
Use Math.PI.
Notice in InterfaceRunner for the final version that the objects are added to an ArrayList of GeometricShapes.
For the draft: write the GeometricShape interface and then modify Parallelogram class to implement the GeometricShape interface.
11B
Modify the Plant class from last week (hw10b) to implement the Comparable interface. If you need it, you can get a working version from the solutions
Plants are ordered first by price with the smallest coming first. If two Plants have the same price, the Plants are ordered alphabetically by name. If this Plant should come before the other Plant,compareTo returns a negative integer. If this Plant should come after the other Plant, it returns a positive integer. Otherwise, it returns 0.
Remember about using Double.compare to compare doubles.
Remember that the compareTo method take a Object as parameter not a Plant (That means you will have to cast)
For the draft, add the "implements Comparable" clause to the Plant class header and implement compareTo as a stub
Note: You will get a compiler warning about "unsafe or unchecked operations" when you compile PlantTester. You can safely ignore it for now.
11C
Write a class to model a Computer. A Computer has a constructor that takes the brand as a String. It also takes a double, gigahertz. Call the instance variables brand and ghz. Gigahertz is a measure of the clock speed of a computer.
Computer implements the the Comparable interface. Computers are ordered by gigahertz. If two Computers have the same speed (gigahertz), then the Computer with the brand that comes first in the lexicographical (alphabetical) order is the smaller. For Example, "Apple" comes before "Surface" alphabetically and so is the smaller.
Computer has methods getGhz() and getBrand().
A toString method is provided for you.
Provide Javadoc
Remember that the compareTo method take a Object as parameter not a Computer (That means you will have to cast)
For the draft, supply the instance variables, the constructor and the getGhz()and getBrand()methods.