Question
I have got this much so far from another question Please find all the Java classes below:- 1. GeometricObject.java public abstract class GeometricObject { public
I have got this much so far from another question
Please find all the Java classes below:-
1. GeometricObject.java
public abstract class GeometricObject {
public abstract double getArea();
public abstract double getPerimeter();
public String toString() {
return "GeometricObject: Area = ?, Perimeter = ? ";
}
}
2. Circle.java
public class Circle extends GeometricObject {
private int radius;
public Circle(int radius) {
super();
this.radius = radius;
}
@Override
public double getArea() {
return Math.PI * Math.pow(radius, 2);
}
@Override
public double getPerimeter() {
return (2 * Math.PI * radius);
}
@Override
public String toString() {
return "Circle: Radius = " + radius + " ,Area = " + getArea() + " ,Perimeter = " + getPerimeter();
}
}
3. GeometricObjectMain.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class GeometricObjectMain {
public static void main(String[] args) throws NumberFormatException, Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Radius of the Circle");
int radius = Integer.parseInt(br.readLine());
Circle circleObj = new Circle(radius);
System.out.println(circleObj.toString());
}
}
Inberitance Part 1) Copy the abstract class GeometricObject below, and save it in the file GeometricObjeet.java: // Lab 10 /Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started