JAVA程式

2006-11-20 8:59 am
有DJAVA唔係好識呀!!功課黎嫁~~唔該幫幫手啦!!!快~~
//The class circle
class circle {
public double radius;
radius = 1; }

public circle (double r){
this.radius = r; }
public double findArea() {
return radius * radius*3.14; }

問題:
1. Using the class Circle, declare and create an array called list[] to store 2 circles.
2. At creation each circle on list[], set its radius equal to 6.
3. Change the radius of the first circle(in an array) from 6 to 10.

唔該幫下手啦~~THZ...

回答 (2)

2006-11-21 8:54 am
✔ 最佳答案
1. Circle[] list = new Circle[ 2 ];

2. for ( int i = 0 ; i < list.length ; i++ ) { list[ i ] = new Circle( 6 ); }

3. list[ 0 ].radius = 10;
2006-11-20 6:53 pm
1. circle list[] = new circle[2];

2. circle list[] = {6, 6};

3. list[0].radius = 10;


收錄日期: 2021-05-03 05:46:06
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061120000051KK00271

檢視 Wayback Machine 備份