-
February 1st, 2009, 02:48 PM
#1
Creating a Oval class?
hey I got to create an oval class for my java class.
Create an Oval class given the following design:
YourLastNameOval
variables: width, length
methods:
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(){
return(length);
}
public void setWidth(){
width = w;
}
public double getWidth(){
return(width);
}
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?
-
February 1st, 2009, 03:44 PM
#2
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?
-
February 1st, 2009, 04:33 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|