1 Replies - 586 Views - Last Post: 23 April 2009 - 03:25 AM

#1 foord  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-April 09

project using abstract class

Post icon  Posted 23 April 2009 - 02:06 AM

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)));
}
}

Is This A Good Question/Topic? 0
  • +

Replies To: project using abstract class

#2 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1