五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

Java oop 的題與答案6:使用程序模擬英雄金幣數(shù),get與set知識(shí),訪問修飾符(有圖)

2019-12-14 15:59 作者:詩書畫唱  | 我要投稿

//使用程序模擬英雄金幣數(shù),使用構(gòu)造函數(shù)設(shè)置默認(rèn)值為300,設(shè)置set方法可以給每個(gè)用戶增進(jìn)金幣,

//get獲取每個(gè)用戶的金幣數(shù),定義靜態(tài)變量統(tǒng)計(jì)總金幣數(shù),創(chuàng)建5個(gè)對(duì)象,并賦值,

//保存到數(shù)組了,求總金幣和平均金幣

package a;


public class student // public可不寫,不寫就有默認(rèn)的修飾訪問符


{

public static void main(String[] args) {

student[] stdAry = new student[5];

stdAry[0] = new student("張三", 80);

stdAry[1] = new student("李 四", 70);

stdAry[2] = new student("王 五", 60);

stdAry[3] = new student("王 三", 60);

stdAry[4] = new student("王 四", 60);

for (int i = 0; i < stdAry.length; i++) {


renshu++;


}


System.out.println("總金幣為" + student.jinBiShuzs);

System.out.println("平均金幣為" + student.jinBiShuzs / renshu);


}


private static int zongchengji;

private static int jinBiShu = 300;// 金幣數(shù)

private static int jinBiShuzs = 0;

private static int renshu = 0;

private String name;// 姓名

private static int getZongchengji() {

return zongchengji;

}


public static void setZongchengji(int zongchengji) {

student.zongchengji = zongchengji;

}


public static int getJinBiShu() {

return jinBiShu;

}


public static void setJinBiShu(int jinBiShu) {

student.jinBiShu = jinBiShu;

}


public static int getJinBiShuzs() {

return jinBiShuzs;

}


public static void setJinBiShuzs(int jinBiShuzs) {

student.jinBiShuzs = jinBiShuzs;

}


public static int getRenshu() {

return renshu;

}


public static void setRenshu(int renshu) {

student.renshu = renshu;

}


public String getName() {

return name;

}


public void setName(String name) {

this.name = name;

}




public student(String name, int jinBiShu) {

jinBiShuzs = jinBiShuzs + jinBiShu+300;

this.name = name;

this.jinBiShu = jinBiShu;// 在構(gòu)造方法里進(jìn)行賦值

System.out.println("姓名為" + name);


}


}

運(yùn)行效果:

get與set知識(shí):

訪問修飾符:




Java oop 的題與答案6:使用程序模擬英雄金幣數(shù),get與set知識(shí),訪問修飾符(有圖)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
应城市| 莱西市| 徐水县| 名山县| 陆河县| 绥芬河市| 拜城县| 永和县| 阿鲁科尔沁旗| 临沧市| 汕尾市| 买车| 武隆县| 鄄城县| 龙井市| 琼中| 宁远县| 枞阳县| 金平| 广饶县| 西藏| 龙口市| 长沙市| 夹江县| 克什克腾旗| 永宁县| 富裕县| 金湖县| 尼玛县| 万载县| 礼泉县| 抚顺县| 瓦房店市| 六枝特区| 巴青县| 长宁县| 新源县| 高碑店市| 阜阳市| 洪湖市| 灵山县|