Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

********Using Java ***** DETAILS You will create 3 shape classes (Circle, Rectangle, Triangle) that all inherit from a single abstract class called AbstractShape which implements

********Using Java *****

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

DETAILS You will create 3 shape classes (Circle, Rectangle, Triangle) that all inherit from a single abstract class called AbstractShape which implements Shape (also created by you). You are also responsible for creating the driver class Assignment5.java (programm that tests your classes and described on page 3) which does the following reads input data from a file instantiates various objects of the three shapes based on the input data stores each in a LinkedList outputs this list to an output file sorts a copy" of this LinkedList of objects outputs the sorted version of the list to the output file outputs the original list to the output file 1. Shape.java This is an interface that has 2 abstract methods, and passes the responsibility of implementing the compareTo method to the class that implements Shape (you may note, normally Comparable is "implemented" by a class. However, an interface cannot implement because interfaces can only contain abstract methods. That said, an interface can only extend other interfaces and the responsibility of actually "implementing" the abstract method(s) of the super class interface is passed on to the sub-classes): public interface Shape extends Comparablef public double calculateArea); public Shape copyShape0 public String getName0 This abstract method is implemented at the concrete level Il also implemented at the concrete level ll implemented in AbstractShape 2. AbstractShape.java public abstract class AbstractShape implements Shape This class should contain an instance field to store the name of each object. The constructor which sets this field should receive the name and a number to be concatenated to the name and then stored in the name field This abstract class will implement the compareTo method passed on from the Shape interface and will pass on the responsibility of implementing calculateArea to the extending sub-classes (compareTo will use the calculateArea method when comparing 2 Shape objects). Along with compareTo, one more concrete method should be included. The following will be used by the sub-classes' toString method public String getName0 Simply returns the name field data

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

List at least three functions of proteins.

Answered: 1 week ago

Question

Why is competency modeling an important practice?

Answered: 1 week ago

Question

Write the difference between sexual and asexual reproduction.

Answered: 1 week ago

Question

What your favourite topic in mathematics?

Answered: 1 week ago

Question

Briefly describe vegetative reproduction in plants.

Answered: 1 week ago

Question

Bachelors degree in Information Systems or Statistics

Answered: 1 week ago