The Artima Developer Community
Sponsored Link

Java Answers Forum
new student

3 replies on 1 page. Most recent reply: Sep 20, 2002 6:31 AM by ducaale

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
ducaale

Posts: 4
Nickname: guure03
Registered: Sep, 2002

new student Posted: Sep 13, 2002 9:04 AM
Reply to this message Reply
Advertisement
I would like to create a class Mine with 2 constractors
one take three doubles(a, b,radius)and the other default constrator suplies default value for coordinate and radius result will be with two decimal.
first constractor is Cir() - return the Cir.
AXX()- return the AXX.
void setradius(double r)- called in the constractor and check the radius against maximumif the radius is grater than max. then setradius reset it to max.
void print Attributes()-print the the radius, Cir and AXX.
public boolean isInside(int a, int b)-test wether is falls inside the Cir.
boundingBox()-print the coordinate for the box that contains the Cir.
move(a,b)-move the origin by specified amount.

thanks


thomas

Posts: 42
Nickname: turbomanic
Registered: Jul, 2002

Re: new student Posted: Sep 14, 2002 6:29 AM
Reply to this message Reply
What section are you having trouble with? If it is the constructors remember that you can have three constructors as long as they each have a different number of arguements in there parameter. The rest of the methods should be basically do the formula and return the result of the formula. Also some are simply change the variable that is listed at the global level.

ducaale

Posts: 4
Nickname: guure03
Registered: Sep, 2002

Re: new student Posted: Sep 16, 2002 9:35 AM
Reply to this message Reply
the lase two:
1- boundingBox();-print the coordinates for the box that contains the circle.
2- move(x,Y)-move the origin by specified amont.

Thanks

ducaale

Posts: 4
Nickname: guure03
Registered: Sep, 2002

Re: new student Posted: Sep 20, 2002 6:31 AM
Reply to this message Reply
here is my question:
Write a class called Circle which has two constructors. One takes three doubles in its constructor corresponding to the X and Y coordinates and the radius. The other default constructor supplies default values for the coordinates and radius. Please round computer results to 2 decimal places when displaying results. The class must include these methods:
public double circumference() ? returning the circumference
public double area() ? returning the area
public void setRadius(double r) ? is called in the constructor and checks the radius against a maximum. If the radius is greater than the maximum, setRadius resets it to the maximum (using the ternary conditional operator)
public void printAttributes() ? prints the coordinates, the radius, the circumference and the area.
public boolean isInside(int x, int y) ? tests whether or not a point falls inside the circle
boundingBox(); ? prints the coordinates for the box that contains the circle
move(x, y) ? moves the origin by a specified amount .

here is my work: I need to double check what I did is Ok since3 I am new student for java.

public class Circlex {

public double x, y, r;
public double MAX;
public double circumference (double x, double y, double r) {
this.x= x;
this.y= y;
this.r= r;
return this.r *3.14 * this.r;
}


public double area() {
return 3.14*r*r;
}
public void setRadius (double r) {
double MAXR;
MAXR = 100.0 ;
if ( this. r > MAXR )
this. r= MAXR;
}
public void printAttributes() {
System.out.println(" r+ circumference + area");
}
// is (x,y) inside the circle?
public boolean isInside( int x, int y) {
double distance;
distance = Math.sqrt(x * x + y * y);
if (distance < r)
return true;
else
return false;
}
void boundBox() {
System.out.println(" Circle");
}
void move ( double x, double y) {
this.x = x;
this.y = y;
}

public static void main(String[] args) {
}
}



Plase let me know.

Thanks

Flat View: This topic has 3 replies on 1 page
Topic: Do I need to purchase a signed applet Previous Topic   Next Topic Topic: elevator

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use