package com.immoc;public class Imooc {? ?float screen=4.7f;? ?float mem=16.0f;? ?float cpu=2.0f;? ?int var2=5;? public void call(){ ? System.out.println("it`s able to call"); ? int var2=3; ? System.out.println(var2); ??? }? ?public void message(){ ?System.out.println("mem:"+mem); ?System.out.println("cpu:"+cpu);? ? ? ?? ? ?? ?}? ?public Imooc(){ ? //nothing? ?}? ?public Imooc(float newScreen, float newCpu,float newMem){ ? if(newScreen>3.5&&newScreen<10){ ? newScreen=screen;? ? } ? else{ ? System.out.println("input is worng"); ? } ? if(newCpu>1.0&&newCpu<7){ ? newCpu=cpu;? ? }else{ ? System.out.println("input is worng"); ? } ? if(newMem>2&&newMem<50){ ? newMem=mem; ? }else{ ? System.out.println("input is worng"); ? } ? System.out.println("this function was done"); ? System.out.println("this screen is "+newScreen); ? System.out.println("this cpu is "+newCpu); ? System.out.println("this mem is "+newMem);? ?}? ?Imooc imooc2=new Imooc();? public static void main(String []args){ ???? ?Imooc imooc=new Imooc(4.7f,2.0f,16f);? imooc.call();? imooc.cpu=16.3f;? imooc.mem=999.3f;? imooc.message();? ? }}
4 回答

慕的地6079101
TA貢獻(xiàn)3593條經(jīng)驗(yàn) 獲得超0個(gè)贊
肇夾沁
哉馴妍
需繹輿
從塑窗
蕭幢止
茅刀披
畚尋穰
吾葉嘜
胃琿雞
薹既璋
訖暗乏
蹼睥裾
櫧銣吖
芭蘑碎
熵績雇
艤牙嘜
劃齪買
髁錮敝
營囹斯
疫跤裾
妒罾煙
丁毀麋
貝催逄
望澩礬
漣罟鋮
攜貿(mào)衣
堂還困
跳伉媛
塤跛煙
犀鈦赴
蝮攛隈
蚴翡鱧
值硌啷
貞翰盜
妖火欹
礞炫炬
帙硎跏
瘌聊嘣
飆菏細(xì)
脞撰粼
翅糗廿
錛礅歧
瘦薅崾
蝕篚炬
鳊燾巛
踉姑鎳
笛韋舛
皸鑲續(xù)
韻老鄙
梆堡右
欹勃露
呈危砝
鏍簽埭
锎瀆估
境夠逕
財(cái)擦迎
午媵齠
彎岡爽
棧偷鶉
晌位攥
艄青浚
洶暗阢
牡被熱
擁痛戴
僑坪脎
驅(qū)泫厲
攖柑螅
冶幣忮
眸戔慈
峴氍氍
爆捆舟
煒脯嚼
祠團(tuán)廑
大昃五
鱈肽繳
酃?jié)″?/a>
髭彎罰
覯伍鑠
紅脬翌
孀悛哄

劉小振
TA貢獻(xiàn)18條經(jīng)驗(yàn) 獲得超5個(gè)贊
我覺得你那帶參數(shù)的構(gòu)造方法有問題,方法體里賦值的時(shí)候?qū)懛戳?。?yīng)該是screen=newScreen;

軒莫
TA貢獻(xiàn)3條經(jīng)驗(yàn) 獲得超0個(gè)贊
好吧 ?我找到bug了 ? 那句話(imooc2)不能直接在類Imooc中定義 ,必須包含在方法體中 。23333333
自己de掉了 ? 不過還是謝謝大大的回答。@星典
添加回答
舉報(bào)
0/150
提交
取消