Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The java.awt. Rectangle class of the standard Java library does not supply a method to compute the area or the perimeter of a rectangle. Provide

image text in transcribed
image text in transcribed
image text in transcribed
The java.awt. Rectangle class of the standard Java library does not supply a method to compute the area or the perimeter of a rectangle. Provide a subclass BetterRectangle of the Rectangle class that has getPerimeter and getArea methods. Do not add any instance variables. In the constructor, call the setlocation and setSize methods of the Rectangle class. I have provided a test program. Do not change it when you submit it. I provided a BetterRectangle class as a starting point. Submit the BetterRetangle.java and the BetterRectangleTesterjava classes in your zip file. import java.awt. *; /I Use only this import statement The java.awt. Rectangle class of the standard Java library does not supply a method to compute the area or perimeter of a rectangle. Provide a subclass BetterRectangle of the Rectangle class that has getPerimeter and getArea methods. Do not add any instance variables. In the constructor, call the setLocation and setsize methods of the Rectangle class. public class ... \{ Ear foemat ing Helis Java. Iang retlect." ort jana, ut IH, He class EetterfectangleTester poblite statie void naln(Strinell aras) throks feceptiot (. Clarse?7xk - Betterfittinglouelars: String nethods - Arraysitostrire (kls-getDeclaregetholsif)) 5trlnit constrictors = Arrayt. tostring(kli, frtCenstructers()): Systea. out, printinf("Testing declaraticeta ...."), Systin.out, pristlin("Crestedt =+ kis): Systen. putipriatlo( Fiectedt clins Metterficctanete") Systee out, printle ("Cocrect seperieleist mi sipecoc); System,out. Printir ("Evected:i troe"): Systomideprintle (Foonstrocton correctly Seclared. + + ctsices) 5yster,oet-fithtlr L (xpectadi true ). System.oet.getntin(-Fxectedi trum "); Syaten-iert,print In (-Ixofectedy, troet) Syaten, out, gedatin ("Laectedy e); ff constructor or, let's test It. Crisect o miti: 11 (ctorok; =k1s. - gutDectaresconifinutor (int.rlash, inf,cteb, foticlass, int, class) - Nowimatance(2, 3,15,17); - Irirche (0j eav object [] I) ). Systen_out, println(-Sets xi- = actual)? dctual - 11s, gethe thod ("gety, has Clatef]S). n divoak (0, neu coject(J) () ; Syste-.out-printin ( Sets.yy = ontuai)i invohar (0, nes ooject?(1) ; Syitia, out,printin(-5ets vidtht: o actual) ) Systra.out, printin( 1 inpictedi is. 02); Anvoteto, ter objecti)(1); Systen, out-printin(*Sets beight: - actaili); Systre.put-prhntind 7victies: 17.0); (f) Mose, test the anthods if ( in mald) I a fmuctar (02 nena object 1I]): Syste oetiprintlai (7aliling getarea: + + actuni): - Invele (02 eer coject[][]} Systen. eat, print ln("Calline getiperincter: + mitanl). Syatra,out, pirintin( "Lopectedi 4e) ) )

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

Show that if A and B are similar, then det A = det B.

Answered: 1 week ago