Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the code given below how would I complete the following. Using your shape class o Add an obstroct drow Graphics gl method to your

Using the code given below how would I complete the following. image text in transcribed
Using your shape class o Add an obstroct drow Graphics gl method to your abstract Shape class - Create a Rectangle, Oval, Triangle, Pentagon&Hexagon class that are all extended from an abstract Shape class (siven below). Extend the Rectangle class to make a Square class. Extend the Oval class to make a Circle class The shape classes wil contain state eformation for the object to be drawn o All the different shapes will need a draw method but each one wil be slighty o All extended classes should also implement a toSt.ring method-it is up to o All extended classes should also implement a equals method to compase two o The Oval, Cincle, Triangle, Rectangle, Square, Hexagon and Pentagon classes dferent you how you want to represent the Shape as a String hapes should have the same number of constructors with the same arguments, in addition te any other fields that are needed to create those shapes To initialize the private instance fields of the Shape class you will need te make cals to the super class constructor. Private Felds and methods of a super class are not directly accessible in the subclasses as if you were in ame class Then initialize fields specific to the partioular Shape class you are implementing o If done cornectly the Square claises will have the least amount of code because it can reuse most of the Rectangle class methods Smilarly Circle class shauld reuse code from t llipe Hint:use super class constructors cerrectly and all this class should have is canstructors and a o Select some random imagels) and fill the larger shapes with that image. You can find more decals about drawimage eptiom at Using your classes, implement the Random Shape Generator application which runs for 7 seconds and draws one random shape every 100 millisecends No shape can be drawn Other requirements are o Your background should be random color than black o Shapes should be of random sines o Shapes should be of random colers diffterent than background o Shapes should be drawn in random locations o Shapes may overlap a lntie bit but try to avoid overlaps that hide half of any shapel .Note Some ol the metheds will nelt be used now and we will come back te therm to add more functionality. The way I designed this lab mighe feel somewhat contrivedl, which was intentional to emphanire the concets. Below is the APl for the shape elass: o o all methods that are not abstract are common to all shapes the abstract methods are methods al shapes will have, but will be dfferent fr each shape

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions