Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java, classes are provided, please keep comments to minimum. thank you Instructions: Make sure that you follow the Program Style and Readability guidelines found in

java, classes are provided, please keep comments to minimum. thank you image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Instructions: Make sure that you follow the Program Style and Readability guidelines found in the Start Here Folder. NOTE: YOU NEED YOUR POINT, RECTANGLE, AND BOX CLASS FOR THIS ASSIGNMENT 1. Start with a working Point class. Refer to the point program created for Lab #1 a. Make Point an abstract class b. Add an abstract method called calcArea 2. Write a new Circle class, a subclass of the Point class a. Add a radius variable to the new class. b. Add constructors i. a default Circle where radius = 15 ii. a 1 argument constructor Circle(radius) 111. use the Super() default constructor for the x, y values (This is the center point of the circle) c. Calculates the area of a Circle object: Area= 3.14 radius * radius d. returns the Area of a Circle object e. Do not store the area in a member variable. f. Override the toString method found in class Point to display (and label) all of the characteristics instance variables) of a Circle object. Do not forget to include the original point instance variables by using the super.toString. 3. Write a new Cylinder class, a subclass of the Circle class. a. Add height as a new variable in this class b. Add constructors i. a default Cylinder() where height = 15 ii. a 1 argument constructor Circle(height) iii. use the Super default constructor for the x, y, radius values c. Add get() and set() methods as needed. d. Override the area method inherited from the Circle class to calculate the outside face area of a Cylinder object i. Calculates: Area= 2 * 3.14 radius * radius + 2 * 3.14 radius height ii. returns the area of a Cylinder object Do not store the area in a member variable. Add a method called volume that: i Calculates the volume of a Cylinder object: Volume = 3.14 * radius * radius * height. 11. returns the volume of a Cylinder object III. Do not store the volume in a member variable. f. Override the toString method inherited from class Circle class to display (and label) all of the characteristics instance variables) of a Cylinder object. Do not forget to include the original point and radius instance variables by using the super.toString 4. Write an executable client class called ShapesABSTester - a separate program - that uses the Point, Rectangle, Box, Circle, Cylinder classes. a. Print your name, Lab number, and date as the first three lines of output. Hard-code the date...do not use the system date. b. Create an array of the Point class PointABSI myShapes - new PointABS[4] c. Populate the array with a new Rectangle(10,20) in myShapes[0]; d. Populate the array with a new Box(30) in myShapes [1]: e. Populate the array with a new Circle(40) in myShares[2]; f. Populate the array with a new Cylinder(50) in myShapes[3). g. Using a for loop examine each item in the array with the instanceof method to determine if the object is a cylinder, circle, box, or rectangle i. Print out the type of object and the object's toStringo ii. Only "type" an object once iii. If an object is a cylinder then do not call it a circle as well iv. If an object is a box then do not call it a rectangle as well 5. Sample Output public class Rectangle extends Point private int width; //instance variable to store private int length; //instance variable to store //Constructor public Rectangle() super(); //call to parent constructor width - 15; //default constructor width = 15 length - 15; //default constructor length - 15 public Rectangle(int newWidth, int newLength) { super(); width = newWidth; length = newLength; // set methods public void setWidth(int newWidth) { width = newWidth; public void setLength(int newLength) { length = newLength; 1/get methods public int getWidth (){ return width; public int getLength (){ return length; //other methods public int calcArea(){ return width * length; public String toString() { return "width = " + width + " length - " + length + " at location " + super.toString(); public class Box extends Rectangle private int height; //instance variable to store depth aspect //Constructor public Box) super(); height - 15; //call to parent constructor //default constructor width, length, height - 15 public Box(int newHeight) { super(); height - newHeight; //set methods public void setHeight (int newtleight) { height - nendleight; //get methods public int getHeight (){ return height; //other methods public int calcArea return super.getWidth() super.getLength() 2 + super.getWidth() height - 2 + super.getLength() - height - 2; public int calcVolume return super.getWidth() super.getLength()* height; public String toString return "height -" height"" + super.toString(); public class Point private int x; //instance variable to store horizontal location private int y; //instance variable to store vertical location //Constructor public Point) x - 0; //default constructor puts the pont at 0,0... the upper lef y = 0; public Point(int newx, int newy) { X = newX; y = newY; //set methods public void setX (int newX){ X = newX; public void sety (int newY) { y = newY; //get methods public int getX () { return x; public int gety (){ return y; public String toString(){ return "x-" + x + y =" + y + " "; Instructions: Make sure that you follow the Program Style and Readability guidelines found in the Start Here Folder. NOTE: YOU NEED YOUR POINT, RECTANGLE, AND BOX CLASS FOR THIS ASSIGNMENT 1. Start with a working Point class. Refer to the point program created for Lab #1 a. Make Point an abstract class b. Add an abstract method called calcArea 2. Write a new Circle class, a subclass of the Point class a. Add a radius variable to the new class. b. Add constructors i. a default Circle where radius = 15 ii. a 1 argument constructor Circle(radius) 111. use the Super() default constructor for the x, y values (This is the center point of the circle) c. Calculates the area of a Circle object: Area= 3.14 radius * radius d. returns the Area of a Circle object e. Do not store the area in a member variable. f. Override the toString method found in class Point to display (and label) all of the characteristics instance variables) of a Circle object. Do not forget to include the original point instance variables by using the super.toString. 3. Write a new Cylinder class, a subclass of the Circle class. a. Add height as a new variable in this class b. Add constructors i. a default Cylinder() where height = 15 ii. a 1 argument constructor Circle(height) iii. use the Super default constructor for the x, y, radius values c. Add get() and set() methods as needed. d. Override the area method inherited from the Circle class to calculate the outside face area of a Cylinder object i. Calculates: Area= 2 * 3.14 radius * radius + 2 * 3.14 radius height ii. returns the area of a Cylinder object Do not store the area in a member variable. Add a method called volume that: i Calculates the volume of a Cylinder object: Volume = 3.14 * radius * radius * height. 11. returns the volume of a Cylinder object III. Do not store the volume in a member variable. f. Override the toString method inherited from class Circle class to display (and label) all of the characteristics instance variables) of a Cylinder object. Do not forget to include the original point and radius instance variables by using the super.toString 4. Write an executable client class called ShapesABSTester - a separate program - that uses the Point, Rectangle, Box, Circle, Cylinder classes. a. Print your name, Lab number, and date as the first three lines of output. Hard-code the date...do not use the system date. b. Create an array of the Point class PointABSI myShapes - new PointABS[4] c. Populate the array with a new Rectangle(10,20) in myShapes[0]; d. Populate the array with a new Box(30) in myShapes [1]: e. Populate the array with a new Circle(40) in myShares[2]; f. Populate the array with a new Cylinder(50) in myShapes[3). g. Using a for loop examine each item in the array with the instanceof method to determine if the object is a cylinder, circle, box, or rectangle i. Print out the type of object and the object's toStringo ii. Only "type" an object once iii. If an object is a cylinder then do not call it a circle as well iv. If an object is a box then do not call it a rectangle as well 5. Sample Output public class Rectangle extends Point private int width; //instance variable to store private int length; //instance variable to store //Constructor public Rectangle() super(); //call to parent constructor width - 15; //default constructor width = 15 length - 15; //default constructor length - 15 public Rectangle(int newWidth, int newLength) { super(); width = newWidth; length = newLength; // set methods public void setWidth(int newWidth) { width = newWidth; public void setLength(int newLength) { length = newLength; 1/get methods public int getWidth (){ return width; public int getLength (){ return length; //other methods public int calcArea(){ return width * length; public String toString() { return "width = " + width + " length - " + length + " at location " + super.toString(); public class Box extends Rectangle private int height; //instance variable to store depth aspect //Constructor public Box) super(); height - 15; //call to parent constructor //default constructor width, length, height - 15 public Box(int newHeight) { super(); height - newHeight; //set methods public void setHeight (int newtleight) { height - nendleight; //get methods public int getHeight (){ return height; //other methods public int calcArea return super.getWidth() super.getLength() 2 + super.getWidth() height - 2 + super.getLength() - height - 2; public int calcVolume return super.getWidth() super.getLength()* height; public String toString return "height -" height"" + super.toString(); public class Point private int x; //instance variable to store horizontal location private int y; //instance variable to store vertical location //Constructor public Point) x - 0; //default constructor puts the pont at 0,0... the upper lef y = 0; public Point(int newx, int newy) { X = newX; y = newY; //set methods public void setX (int newX){ X = newX; public void sety (int newY) { y = newY; //get methods public int getX () { return x; public int gety (){ return y; public String toString(){ return "x-" + x + y =" + y +

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions

Question

4. Are there any disadvantages?

Answered: 1 week ago

Question

3. What are the main benefits of using more information technology?

Answered: 1 week ago

Question

start to review and develop your employability skills

Answered: 1 week ago