• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

draw oval shape

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i made this class to draw the oval but am not sure if its right and i dont know how to call it in the main

 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That code is well‑nigh illegible because it has not been spaced or indented properly. Please use the button to go back and sort out the code.
You have the wrong arguments for the Ellipse2D constructor. Please look them up.
Delete that empty constructor, unless you particularly want a 0.0×0.0 ellipse.
You cannot call paint unless you have a Graphics object available, which mean on a display/GUI. That method call will never compile in a main method.
Your other method calls will work, but you are not using their return values. Maybe you should print them:- System.out.println(myEllipse.getArea());
Your class names are incorrect; they should be Oval, Shape2D. Only ever use _ in constant names. Don’t write your own PI; use Math.PI.
Never use pow(x, 2). Use x * x.
 
hadeel marghlany
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please can you explain the graphic part more because its my first time using this library and am totaly lost
 
hadeel marghlany
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im sorry i thought my code is well sorted and easy to read

the constructers:
the first one is empty beacause it is inherited from a superclass which any way will be added atumaticlly but our professor wanted us to write it

the second constructer should input only two things the short raduis and a long raduis then the
compovalperimeter() and compovalarea() methods take this paramters and calculate it
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

hadeel marghlany wrote:im sorry i thought my code is well sorted and easy to read

Apology accepted (), but the code is not at all easy to read.

the constructers:
the first one is empty beacause it is inherited from a superclass which any way will be added atumaticlly but our professor wanted us to write it

. . .

Constructors are not inherited, and there would be no constructor added automatically. You should query that instruction.

You can only use Graphics if you have a Graphics object. You usually only get a Graphics object on a GUI. You will not be able to put that paint() call in the main method because there is nowhere you can obtain the correct argument.
 
hadeel marghlany
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so how can i do the draw oval function what library should i use i have read tons of website and tell now i dont know what to do
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest you read the Java 2D trail.
 
hadeel marghlany
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got it thankyou
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic