Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA HELP: Create a public interface Consolelo. The interface should declare two methods: updateFromConsole and writeToConsole. These methods should have neither parameters nor return values.

JAVA HELP:

image text in transcribed

image text in transcribed

Create a public interface Consolelo. The interface should declare two methods: updateFromConsole and writeToConsole. These methods should have neither parameters nor return values. Also, create a generic interface comparable GeometricFigure<...> which extends the built-in interface Comparable<...> and which ensures, using generics, that only objects of subclasses of GeometricFigure are comparable with each other (but it should not be restricted to comparing octagons, but should also be usable with other subclasses of GeometricFigure2). The code for GeometricFigure2 is supplied below. Create a class Octagon for regular octagons (symmetric octagons where all sides have the same length) which extends GeometricFigure2 and implements your interfaces Consolelo and ComparableGeometricFigure<...>. writeToConsole should print the field values and the area of the octagon. updateFromConsole should prompt the user interactively for a number (hint: java.util.Scanner) and update the side length of this octagon to this value. Your implementation of compare To in Octagon should compare two octagons in terms of their areas. Make sure that your compare To implementation can compare only octagons with each other, and that the Java compiler ensures this at compile time (again, using generics). Finally, add a static main method with some appropriate code which demonstrates the use of updateFromConsole, compare To and writeToConsole. abstract class GeometricFigure2 { public static final double PI = 3.141592653; private baslean filled; public GeometricFigure2() { filled = false; } public boolean isfitted) { return filled; } public void setFilled (kaalean filled) { this filled = filled; } public void display() { System.out.println("This is some geometric figure."); } public abstract double salsArea(); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago