CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Creating a Oval class?

  1. #1
    Join Date
    Jan 2009

    Question Creating a Oval class?

    hey I got to create an oval class for my java class.

    Create an Oval class given the following design:


    variables: width, length

    setWidth - changes the width. Requires one parameter for width.
    setLength - changes the length. Requires one parameter for length.
    getWidth - returns the oval width.
    getLength - returns the oval length.
    area - returns the area of the oval ((l*w)*0.8) given the current width and length

    Write appropriate client code to test the class. Call the client class simply YourLastName

    This is what I have so far.

    public class McIntoshOval {
    public double length, width;

    public Oval(){
    public int width = 5;
    public int length = 10;

    public Oval(double l, double w){
    length = l;
    width = w;

    public void setLength(){
    length = l;

    public double getLength(){

    public void setWidth(){
    width = w;

    public double getWidth(){

    public double area (){
    return((l*w)*0.8) ;

    public static void main(String[] args) {

    Can anyone give me some help, perhaps stir me in the right direction and let me know of things I am missing Id really appreciate it. Thanks.

    And client code?? What is that?

  2. #2
    Join Date
    Sep 2006
    Eastern, NC, USA

    Re: Creating a Oval class?

    the client class simply has a main method, creates one or more Oval objects and tests them.

    Regarding help: what specific questions do you have?

  3. #3
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999

    Re: Creating a Oval class?

    If you provide methods to set the length or the width, you need to allow the desired values to be passed into them.

    Computers are good at following instructions, but not at reading your mind...
    D. Knuth
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)