第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

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

package Shape; //父類


public abstract class Shape {

public abstract void ZhouChang();

public abstract void Area();


} ?


//長方形類

package Shape;


public class Rectangle extends Shape {

? ? int length;

? ? int width;

public Rectangle(int a,int b)

{

length=a;

width=b;

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

}

public void ZhouChang()

{

int total=(length+width)*2;

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

}

public void Area()

{

int area=length*width;

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

//System.out.println("長方形的面積為"+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("長方形周長為"+Sum);

}

public void ZhouChang()

{

double total=2*PI*R;

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

}

public void Area()

{

double area=PI*R;

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

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

}


}


//測試類

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)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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