hello i am david foord i am studying for sun certified qualification,i am stuck on a certain part of my program on abstract class,i am doing a program excercise at the moment but seem to be missing a trick or two on the program please could you advise me please in amy way to see where i am going wrong with my program i get two errors when i compile
i enclose my source code below many thanks!!!!
import static java.lang.Math.sqrt;
/**
*
* @author DAVID FOORD
*/
class Shape
{
public static void main(String[] args)
{
Dimension2 d2 = new Dimension2();
d2.pi = 3.14f;
d2.radius = 15;
d2.circle();
Dimension3 d3 = new Dimension3();
d3.height = 20;
d3.pi = 3.14f;
d3.radius = 20;
d3.cone();
}
}
abstract class ShapeMain
{
float pi ;
int radius;
int height;
abstract void circle();
//abstract void cone();
}
class Dimension2 extends ShapeMain
{
void circle()
{
System.out.println("The area of the Circle is: " + (pi *(radius * radius)));
System.out.println("The circumference of the Circle is: " + (pi *(2 * radius)));
}
}
class Dimension3 extends Dimension2
{
void cone()
{
System.out.println("The volume of the cone is: " + (height*pi*(radius*radius/3)));
System.out.println("The area of the cone is: " + (pi*radius(math.sqrt((height*height) + (radius * radius))) + pi*(radius*radius)));
}
}
project using abstract class
Page 1 of 11 Replies - 454 Views - Last Post: 23 April 2009 - 03:25 AM
Replies To: project using abstract class
#2
Re: project using abstract class
Posted 23 April 2009 - 03:25 AM
Hi.
The Programming help forums are on the left hand side of screen and they would be of vital help if you place this question in the correct forum. Also, could you please place the code in the [code] tags.
Thanks.
The Programming help forums are on the left hand side of screen and they would be of vital help if you place this question in the correct forum. Also, could you please place the code in the [code] tags.
Thanks.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|