Hello,
I am working on the problem of creating an abstract class Shape also with Package shape and then creating a subclasses Circle, Square and etc.
I belive, i don't have a complete understanding of an abstract. Anyways i keep getting an error: " Shape.Circle is not abstract and does not override abstract method perimeter() in Shape.Shape
I am not sure what that means. Does anyone know whats going on?
Here is my main, abstract class and subclass circle:
// Main
Package Shape;
import java.io.*;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException
{
BufferedReader stdin = new BufferedReader ( new InputStreamReader( System.in ) ); // Initiating Input Stream from the user
String temp;
double r;
Circle c = new Circle(); // Class Circle initiation
Square s = new Square (); // Class Circle initiation
Rectangle rad = new Rectangle (); // Class Circle initiation
// User input reader
System.out.println("Please enter the necessary component to calculate the area (radius, side etc.): ");
temp = stdin.readLine();
r = Double.parseDouble(temp);
// Circle output
System.out.println("The area of a Circle is " + c.area(r) + " squared units");
System.out.println("The perimeter of a Circle is " + c.perimeter(r) + " units");
// Abstract class Shape
Package Shape;
abstract public class Shape
{
public String color;
public void setColor(String c) {
color = c;
}
public String getColor() {
return color;
}
abstract double area();
abstract double perimeter();
}
// Subclass circle
/
package Shape;
public class Circle extends Shape
{
// Method area
double area(double r)
{
return 3.14 * r * r;
}
double perimeter(double r)
{
return Math.abs(2 * 3.14 * r);
}
}
Thank you in advance