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

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

Java oop代碼5(原創(chuàng)方法):添加非靜態(tài)的方法,買手機(jī)時(shí),設(shè)置手機(jī)名稱

2019-12-16 23:33 作者:詩書畫唱  | 我要投稿

//創(chuàng)建一個(gè)Human類

//添加一個(gè)非靜態(tài)屬性String mobile(手機(jī)),添加非靜態(tài)的方法:買手機(jī)時(shí),設(shè)置手機(jī)名稱

//丟手機(jī)時(shí),手機(jī)名稱設(shè)置為null

//添加一個(gè)靜態(tài)屬性long count(世界人口總數(shù)) =?

//1500000000;添加靜態(tài)方法:出生(人口數(shù)+1),死亡(人口數(shù)-1)。在main方法中調(diào)用。


package a;


import java.util.*;


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

private String mobile;// 用private會(huì)更安全,但要用上getXXX() setxxx()

private static long count = 1500000000;


public String getMobile() {

return mobile;

}


public void setMobile(String mobile) {

this.mobile = mobile;

}


public static long getCount() {

return count;

}


public static void setCount(long count) {

Human.count = count;

}


public void info() { // 定義一個(gè)方法


Scanner sstring = new Scanner(System.in);

Scanner sint = new Scanner(System.in);

System.out.println("請(qǐng)輸入你的操作:1.買手機(jī)? 2.丟手機(jī)");


int num = sint.nextInt();


if (num == 1) {


System.out.println("請(qǐng)輸入手機(jī)名稱");


String uname = sstring.next();

System.out.println("買手機(jī),手機(jī)名稱為" + uname);

} else if (num == 2) {

mobile = null;

System.out.println("丟手機(jī)時(shí),手機(jī)名稱設(shè)置為:" + mobile);


} else {


System.out.println("輸入錯(cuò)誤");


}

}






public static void me() {

count = count + 1;

System.out.println("出生(人口數(shù)+1):" + count);

count = count - 1;

System.out.println("死亡(人口數(shù)-1):" + count);


}


public static void main(String[] args) {



Human a = new Human();

a.info();


Human.me();


}


}



Java oop代碼5(原創(chuàng)方法):添加非靜態(tài)的方法,買手機(jī)時(shí),設(shè)置手機(jī)名稱的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
临夏县| 公主岭市| 白城市| 莲花县| 诏安县| 公主岭市| 湛江市| 获嘉县| 锡林郭勒盟| 龙井市| 义马市| 临猗县| 盐津县| 抚州市| 津南区| 綦江县| 宁海县| 青铜峡市| 石城县| 达拉特旗| 彝良县| 舟山市| 天水市| 台州市| 平湖市| 开江县| 昔阳县| 濮阳市| 泸西县| 甘南县| 怀集县| 同德县| 抚顺市| 宁化县| 蕉岭县| 长武县| 天祝| 兴和县| 瑞昌市| 高要市| 宁海县|