Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Procedure: Write a Java program that: 1. Has an object class named L3XXxxRegOct that is a concrete subclass of the Shape class from Chapter 4

image text in transcribed

Procedure: Write a Java program that: 1. Has an object class named L3XXxxRegOct that is a concrete subclass of the Shape class from Chapter 4 (Comparable electronic version in the sample code.) that represents an Regular Octagon. 2. The class must include appropriate implementations of the required abstract methods. 3. The class must override toString() in a descriptive fashion, displaying any instance variables and the area, each labeled unambiguously. The string must easily fit on one line of the console. 4. Add constructors/accessors/mutators for all instance variables. 5. Retain the default Comparable logic for Shape and L3XXxxRegoct. 6. Performs the following tasks in the main() of L3XXxxRegOct: a. Declare and instantiate an instance of an L3XXxxRegoct array and insert at least 20 of your octagon instances, each constructed with a random (double) dimension. b. Display the contents of the array after the octagons have been inserted, one instance per line. Precede the output with a descriptive heading. c. Sort the octagons in place in ascending order using a static method you write named lab3Sort that takes a comparable array as its lone parameter. (More details below.) d. Display the sorted array contents, one instance per line, with a descriptive heading and whitespace separation from the unsorted group. Your sort algorithm can be any standard sort that is neither Bubble Sort nor a Bogosort. Make an honest attempt to code a sort you already know rather than just copying it if possible, but it must be coded by you (i.e. calling a library method to do your sort for you is not acceptable.) Put both classes in a package named cis232.lab3 (copy the Weiss Shape class and put it in that package). Don't forget the comment block. Don't forget your newlold friend the Random class from Chapter 2. The Math class may make an appearance as well. Name your class (and source file) L3XXxxRegoct.java, where XXxx is the first initial and first 3 letters of one person's name. Upload (only) your octagon's .java file to Canvas as a zip. Procedure: Write a Java program that: 1. Has an object class named L3XXxxRegOct that is a concrete subclass of the Shape class from Chapter 4 (Comparable electronic version in the sample code.) that represents an Regular Octagon. 2. The class must include appropriate implementations of the required abstract methods. 3. The class must override toString() in a descriptive fashion, displaying any instance variables and the area, each labeled unambiguously. The string must easily fit on one line of the console. 4. Add constructors/accessors/mutators for all instance variables. 5. Retain the default Comparable logic for Shape and L3XXxxRegoct. 6. Performs the following tasks in the main() of L3XXxxRegOct: a. Declare and instantiate an instance of an L3XXxxRegoct array and insert at least 20 of your octagon instances, each constructed with a random (double) dimension. b. Display the contents of the array after the octagons have been inserted, one instance per line. Precede the output with a descriptive heading. c. Sort the octagons in place in ascending order using a static method you write named lab3Sort that takes a comparable array as its lone parameter. (More details below.) d. Display the sorted array contents, one instance per line, with a descriptive heading and whitespace separation from the unsorted group. Your sort algorithm can be any standard sort that is neither Bubble Sort nor a Bogosort. Make an honest attempt to code a sort you already know rather than just copying it if possible, but it must be coded by you (i.e. calling a library method to do your sort for you is not acceptable.) Put both classes in a package named cis232.lab3 (copy the Weiss Shape class and put it in that package). Don't forget the comment block. Don't forget your newlold friend the Random class from Chapter 2. The Math class may make an appearance as well. Name your class (and source file) L3XXxxRegoct.java, where XXxx is the first initial and first 3 letters of one person's name. Upload (only) your octagon's .java file to Canvas as a zip

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

Students also viewed these Databases questions