最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

新手寫的課后練習(xí),感覺基本能滿足題目的要求... 有什么需要改進(jìn)的地方嗎?

package Shape; //父類


public abstract class Shape {

public abstract void ZhouChang();

public abstract void Area();


} ?


//長(zhǎng)方形類

package Shape;


public class Rectangle extends Shape {

? ? int length;

? ? int width;

public Rectangle(int a,int b)

{

length=a;

width=b;

//System.out.println("長(zhǎng)方形周長(zhǎng)為"+Sum);

}

public void ZhouChang()

{

int total=(length+width)*2;

System.out.println("該長(zhǎng)方形的周長(zhǎng)為: "+total);

}

public void Area()

{

int area=length*width;

System.out.println(" ? ? ? ?面積為: "+area);

//System.out.println("長(zhǎng)方形的面積為"+area);

}

}

//圓形類

package Shape;


public class Circle extends Shape {

? public final double PI=3.1415;

? int R;

public Circle(int r)

{

this.R=r;//System.out.println("長(zhǎng)方形周長(zhǎng)為"+Sum);

}

public void ZhouChang()

{

double total=2*PI*R;

System.out.println("該圓形的周長(zhǎng)為: "+total);

}

public void Area()

{

double area=PI*R;

System.out.println(" ? ? ? ?面積為: "+area);

//System.out.println("長(zhǎng)方形的面積為"+area);

}


}


//測(cè)試類

package Shape;


public class Initial {

static void main(String[] args) {

// TODO Auto-generated method stub

? ? ? ? Shape one=new Rectangle(2,3);

? ? ? ? one.ZhouChang();

? ? ? ? one.Area();?

? ? ? ? Shape two=new Circle(3);

? ? ? ? two.ZhouChang();

? ? ? ? two.Area();

? ?

}


}


正在回答

1 回答

  1. 包名統(tǒng)一小寫 shape

  2. 方法名一般頭字母小寫

  3. public final double PI=3.1415; ?public可以去掉吧 ,我不確定

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

新手寫的課后練習(xí),感覺基本能滿足題目的要求... 有什么需要改進(jìn)的地方嗎?

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)