Question: JAVA HELP: Create a public interface 'Shapes'. The interface should declare two methods: 'update' and 'write' Both methods should not have parameters or return values.
JAVA HELP:
Create a public interface 'Shapes'. The interface should declare two methods: 'update' and 'write' Both methods should not have parameters or return values.
A generic interface should be created too, 'ComparableShape<>' which extends built-in interface Comparable<> and which ensures, using generics, that only objects of subclasses of Shape2 are comparable with each other (but it should not be restricted to comparing pentagons, but should also be usable with other subclasses of Shape2).
Create a class 'Pentagon' for a regular Pentagon shape (all sides - similar length) which extends 'Shape2' and implements interfaces 'Shapes' and 'ComparableShape<>'.
'write' should print the field values and area of the pentagon. 'update' should prompt the user interactively for a number and update the side length of this pentagon to this value.
Your implementation of compareTo in Pentagon should compare two pentagons in terms of their areas. Make sure that your compareTo implementation can compare only pentagons with each other, and that the Java compiler ensures this at compile time (using generics).
Conclusively, create a static main method with suitable code which presents the use of 'update', 'compareTo' and 'write'.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
