Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error message

 
ricky barnes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
get complie error "missing method body or declare abstract" when extending abstact class.
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ricky,
This means that your abstract class has declared a method that your Imp class has not implemented.
HTH,
M
 
ricky barnes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max,
First thank you for your help but we are still get the same error message. I thought that encluding the code and the error message may help you help us.
Ricky
// July 17, 2002
// Project 7
// This project consists of an abstract class and three concrete
// classes (this is one). There is also a test program
// which will prove the exercise.
// Java packages
import java.awt.*;
import java.text.*;
import java.awt.event.*;
import javax.swing.*;
public class MyRectangle extends TwoDShape
{
protected float length;
protected float width;

public MyRectangle()
{
setLength (1);
setWidth (1);
}

public MyRectangle (float rectLength, float rectWidth)
{
setLength(rectLength);
setWidth(rectWidth);
} // end constructor

public void setLength(float rectLength);
{
length = (rectLength >= 1 ? rectLength : 1);
}
public void setWidth(float rectWidth);
{
width = (rectWidth >= 1 ? rectWidth : 1);
}
public float getArea()
{
return length;
}// end getLength
public float getPerimeter()
{
return width;
}// end getWidth

public float calcArea()
{
return area = width * length;
}// end calcArea

public float calcPerimeter()
{
return perimeter = (length + width) * 2;
}// end calcPerimeter

public String toString()
{
return "Length = " + length +
"\nWidth = " + width;
} // end toString
public String getName()
{
return "Rectangle: ";
} // end getName

} // end MyRectangle
--------------------Configuration: JDK version 1.3 <Default>--------------------
D:\Project7\MyRectangle.java:30: missing method body, or declare abstract
public void setLength(float rectLength);
^
D:\Project7\MyRectangle.java:32: cannot resolve symbol
symbol : variable rectLength
location: class MyRectangle
length = (rectLength >= 1 ? rectLength : 1);
^
D:\Project7\MyRectangle.java:32: cannot resolve symbol
symbol : variable rectLength
location: class MyRectangle
length = (rectLength >= 1 ? rectLength : 1);
^
D:\Project7\MyRectangle.java:35: missing method body, or declare abstract
public void setWidth(float rectWidth);
^
D:\Project7\MyRectangle.java:37: cannot resolve symbol
symbol : variable rectWidth
location: class MyRectangle
width = (rectWidth >= 1 ? rectWidth : 1);
^
D:\Project7\MyRectangle.java:37: cannot resolve symbol
symbol : variable rectWidth
location: class MyRectangle
width = (rectWidth >= 1 ? rectWidth : 1);
^
6 errors
Process completed.
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ricky,
You need to remove the ';' after the declaration

HTH,
M
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and 'public void setWidth(float rectWidth);' as well
/Rene
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic