第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

方法setsp無法使用?

方法setsp無法使用?

黃森h(huán)uang 2016-09-22 21:43:26
package 學生成績管理;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;import java.util.Scanner;class Sp { private String bianhao; private String mingcheng; private double jiage; Sp(String bianhao,String mingcheng,double jiage) { this.bianhao=bianhao; this.mingcheng=mingcheng; this.jiage=jiage; } public String getBianhao() { return bianhao; } public void setBianhao(String bianhao) { this.bianhao = bianhao; } public String getMingcheng() { return mingcheng; } public void setMingcheng(String mingcheng) { this.mingcheng = mingcheng; } public double getJiage() { return jiage; } public void setJiage(double jiage) { this.jiage = jiage; }}class Spg{ ArrayList<Object> aa=null; Scanner in=null; Spg() { aa=new ArrayList(); in=new Scanner(System.in); } public void addsp(Sp Sp) { aa.add(Sp); System.out.println("增加成功"); } public void spxx(String bh) { int i; int c=aa.size(); for(i=0;i<c;i++) { Sp sr=(Sp)aa.get(i); if(sr.getBianhao().equals(bh)) { System.out.println("信息如下:"); System.out.println("食品編號:"+sr.getBianhao()); System.out.println("食品名稱:"+sr.getMingcheng()); System.out.println("食品價格:"+sr.getJiage()); } } if(i==c) { System.out.println("輸入有誤"); } } public void delsp(String bh) { int i; if(aa.size()==0) { System.out.println("沒有信息"); } for(i=0;i<aa.size();i++) { Sp sr=(Sp)aa.get(i); if(sr.getBianhao().equals(bh)) { aa.remove(i); } } if(i==aa.size()&&aa.size()!=0) { System.out.println("輸入有誤"); } } public void setsp(String bh) { int i; for(i=0;i<aa.size();i++) { Sp sr=(Sp)aa.get(i); if(sr.getBianhao().equals(bh)) { System.out.println("請輸入新的名稱"); String c=in.next(); sr.setBianhao(c); System.out.println("請輸入新的價格"); double a=in.nextDouble(); sr.setJiage(a); //aa.remove(i,bh); } } if(i==aa.size()&&aa.size()!=0) { System.out.println("輸入有誤"); } } public void exitsp() { System.out.println("謝謝使用"); System.exit(0); } public void addsp(String bh, String mg, double jg) { // TODO Auto-generated method stub }}public class Lianxi2{ public static void main(String []args) throws IOException { Spg gl=new Spg(); BufferedReader sr=new BufferedReader(new InputStreamReader(System.in)); while(true) { System.out.println("請按如下提示操作:"); System.out.println("按1增添食品種類"); System.out.println("按2查詢食品"); System.out.println("按3刪除食品"); System.out.println("按4修改食品"); System.out.println("按0退出系統(tǒng)"); String srt=sr.readLine(); if(srt.equals("1")) { System.out.println("請?zhí)砑邮称访Q"); String mg=sr.readLine(); System.out.println("請?zhí)砑邮称肪幪?); String bh=sr.readLine(); System.out.println("請?zhí)砑邮称穬r格"); double jg=Double.parseDouble(sr.readLine()); gl.addsp(bh,mg,jg); }else if(srt.equals("2")) { System.out.println("請輸入食品編號"); String bh=sr.readLine(); gl.spxx(bh); }else if(srt.equals("3")) { System.out.println("請輸如食品編號"); String bh=sr.readLine(); gl.delsp( bh); }else if(srt.equals("4")) { System.out.println("請輸如食品編號"); String bh=sr.readLine();gl.setsp( bh);這里的方法發(fā)現(xiàn)根本無法使用,求大神指點錯誤 }else if(srt.equals("0")) {; gl.exitsp( ); } } }}
查看完整描述

1 回答

?
ziom

TA貢獻948條經(jīng)驗 獲得超1109個贊

這樣一段長而臭的代碼,還沒有格式化,怎么看 - -

查看完整回答
1 反對 回復 2016-09-23
  • 1 回答
  • 0 關(guān)注
  • 1511 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號