PROGRAMMING:Ring class design
Write a ring class java program< br/>
A defines two data members of the ring class, namely inner radius and outer radius. These attributes are encapsulated by get and set methods< br/>
B define ring (int innerradius, int outerradius), and add system. Out. Println ("constructor") to the parametric construction method< br/>
C to complete the nonparametric construction method ring (), which requires that this be used in the nonparametric construction method to call the parametric construction method to assign values to two radii (outer radius assigned 3, inner radius assigned 1) < br / > C
The public int getarea() method defined in the D-ring class can return its area. After calculating the area, it is forced to convert to an integer value, π Use math. PI< br/>
In the main class, it forms a ring class object. The two radii of the ring are read in through the keyboard, and the area is output after the area is calculated by calling the area method< br/>
Then define a ring object again, call the nonparametric construction method, call the area method, and output the area after calculating the area.
###Input format:
Input the inner radius in one line, then the outer radius.
###Output format:
Output the area of the ring in a row.
###Input example:
Here is a set of inputs. First the inner radius, then the outer radius, for example:
```in
1 2
```
###Output example:
The corresponding output is given here. For example:
```out
constructor
nine
constructor
twenty-five
```
answer:If there is no answer, please comment
A defines two data members of the ring class, namely inner radius and outer radius. These attributes are encapsulated by get and set methods< br/>
B define ring (int innerradius, int outerradius), and add system. Out. Println ("constructor") to the parametric construction method< br/>
C to complete the nonparametric construction method ring (), which requires that this be used in the nonparametric construction method to call the parametric construction method to assign values to two radii (outer radius assigned 3, inner radius assigned 1) < br / > C
The public int getarea() method defined in the D-ring class can return its area. After calculating the area, it is forced to convert to an integer value, π Use math. PI< br/>
In the main class, it forms a ring class object. The two radii of the ring are read in through the keyboard, and the area is output after the area is calculated by calling the area method< br/>
Then define a ring object again, call the nonparametric construction method, call the area method, and output the area after calculating the area.
###Input format:
Input the inner radius in one line, then the outer radius.
###Output format:
Output the area of the ring in a row.
###Input example:
Here is a set of inputs. First the inner radius, then the outer radius, for example:
```in
1 2
```
###Output example:
The corresponding output is given here. For example:
```out
constructor
nine
constructor
twenty-five
```
answer:If there is no answer, please comment