Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Java Language Add a class Octagon to work with the Shape, Triangle, Rectangle classes. An octagon has eight sides that you can assume are

Using Java Language image text in transcribed
Add a class Octagon to work with the Shape, Triangle, Rectangle classes. An octagon has eight sides that you can assume are all the same length. (Hint: how many attributes will this class need then? Can we use just one? ). The area of an octagon is : side * side. The class should have get and set methods, toString, equals, and area and perimeter methods. It should have a no-args (defaulto parameter) constructor as well as one that takes a double for the side length. The default side length should be 1.0 a. Draw a UML diagram for the class. b. Code the class. c. Create a test program that has the following: A method that generates an array of n Octagons, that have random side lengths in the interval [a,b). nga and b should be parameters for the method. A method that prints the array. A method that returns the index of the largest octagon, where you use side length as the determinant it "larger". A main method that tests each of these methods by calling them one or more times. Add a class Octagon to work with the Shape, Triangle, Rectangle classes. An octagon has eight sides that you can assume are all the same length. (Hint: how many attributes will this class need then? Can we use just one? ). The area of an octagon is : side * side. The class should have get and set methods, toString, equals, and area and perimeter methods. It should have a no-args (defaulto parameter) constructor as well as one that takes a double for the side length. The default side length should be 1.0 a. Draw a UML diagram for the class. b. Code the class. c. Create a test program that has the following: A method that generates an array of n Octagons, that have random side lengths in the interval [a,b). nga and b should be parameters for the method. A method that prints the array. A method that returns the index of the largest octagon, where you use side length as the determinant it "larger". A main method that tests each of these methods by calling them one or more times

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 Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions