无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(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)遵守國家法律
锡林浩特市| 嘉峪关市| 太仓市| 荔波县| 张家界市| 唐山市| 进贤县| 兴仁县| 邯郸县| 闵行区| 绵阳市| 华池县| 慈溪市| 冕宁县| 康保县| 准格尔旗| 南和县| 四平市| 镇江市| 洞头县| 南丰县| 罗源县| 安吉县| 洪湖市| 开封市| 花垣县| 仲巴县| 肥东县| 孟津县| 揭西县| 兴文县| 沾化县| 遂平县| 新沂市| 西城区| 班玛县| 利川市| 宁城县| 清涧县| 宁都县| 肥乡县|