Home > Back-end >  Such a big help
Such a big help

Time:09-17

Please follow the following requirements to design a kind of Circle Circle, and test, the requirements are as follows:
1) the Circle class attribute contains a radius radius;
2) give this attribute defines two methods, a method is used to set values, another way to get the value;
3) the Circle class defined in a no-parameter constructor and contains a constructor parameter, the radius parameter attribute assignment;
4) to define a method for the area of a circle area, requires method in which a parameter, used to pass the value of the radius;
5) in the main method to create two Circle object, one using a no-parameter constructor, then call assignment method to set the value of an attribute radius of 2.56, use a no-parameter constructor, to radius in the method of constructing assignment 13.85; Call two object area method, calculate and output the area of the two objects,

CodePudding user response:

Homework must write their own point to

CodePudding user response:

Support on the first floor, this belongs to the foundation of the foundation, must write their own, basic things to remember

CodePudding user response:

Didn't understand the meaning of the author, whether that is
 public class Circle {
private double radius;

Public void setRadius (double radius) {
Enclosing the radius=radius;
}

Public double getRadius () {
Return this. The radius;
}

Public Circle () {

}

Public Circle radius, (double) {
Enclosing the radius=radius;
}


Public String getArea (double radius) {
Double radius, a=3.14 * * radius;
Strings str1=the String. Format (" radius. % 2 f of the area of a circle to %. 2 f ", enclosing getRadius (), a);
Return the str1;
}

Public static void main (String [] args) {
Circle a=new Circle (13.85);
System. The out. Println (al-qeada etArea (al-qeada etRadius ()));

Circle b=new Circle ();
B.s etRadius (2.56);
System. The out. Println (b.g etArea (b.g etRadius ()));
}
}

Results:

  • Related