CS46A Fall 18

11A

Implement the GeometricShape interface. The GeometricShape interface will have one method, area, which takes no parameters and returns a double.

You are provided with three classes: ParallelogramCircle, 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.

The Parallelogram class and the GeometricShape interface will not change in the final, but you will need to paste them into Codecheck.

11A draft:
11A final:

11B

Modify the Plant class from last week (hw10b) to implement the Comparable interface from the Java library. Do not write your own Camparable interface.

Codecheck contains a working version of the Plant class, if you need it.

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 the method public int compareTo (Object otherObject) 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.

11B draft:
11B final:

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.

11C draft:
11C final: