国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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)遵守國家法律
永仁县| 定州市| 峨眉山市| 东莞市| 镇宁| 张家口市| 寻乌县| 平塘县| 广州市| 玉门市| 蒲江县| 开封市| 兴化市| 南投县| 新化县| 凉城县| 桐梓县| 诸暨市| 新河县| 乐山市| 沭阳县| 沐川县| 那曲县| 措勤县| 桓台县| 成安县| 南阳市| 临夏市| 望江县| 宜良县| 蛟河市| 浏阳市| 区。| 延寿县| 绿春县| 伊金霍洛旗| 金塔县| 扶风县| 孟连| 怀来县| 五大连池市|