JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java 新手區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 求救~~~~存款機的bug
rusilent





發文: 6
積分: 0
於 2010-03-30 19:50 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import java.io.*;
 
class account
{
  String account = "-1";
  int money = 0;
  
  account(String ID, int money)
  {
    this.account = ID;
    this.money = money;
  }
 
  void takeMoney(int m)
  {
    System.out.println(this.account+"f");
  }
  void saveMoney(int m)
  {
    this.money += m;  
  }
  void showMoney()
  {
    System.out.println(this.account + " 存款餘額為 : " + this.money);
    return this.money;
  }
}
 
class Bank
{
  public static void main(String args[])throws IOException
  {
    
    int action = 0;
    int index = 0;
    account user[] = new account[255];
    while(action != -1)
    {
      System.out.println("輸入使用的功能\n1.建立帳戶\n2.存款\n3.提款\n4.查詢餘額");
      System.out.println("輸入-1離開");
      BufferedReader Bf = new BufferedReader(new InputStreamReader(System.in));
      String buffer = Bf.readLine();
      action = Integer.parseInt(buffer);
      
      if(action == 1) // create a new account
      {
        System.out.println("輸入新增帳戶名:");
        BufferedReader Buf = new BufferedReader(new InputStreamReader(System.in));
        String ID = Buf.readLine();
        user[index] = new account(ID, 0);
        index++;
      }
      else if(action == 2)
      {
        int money;
        int m;
        int usable = 0;
        int select;
        System.out.println("可操作的帳號編號:");
        for(usable = 0; usable < index; usable++)
        {
          System.out.println("編號 : " + usable + " 帳號名稱 : " + user[usable].account);
        }
        System.out.println("Select user :");
        BufferedReader Bs = new BufferedReader(new InputStreamReader(System.in));
        String s = Bs.readLine();
        select = Integer.parseInt(s);
        if(select > usable){
          //
        }
        else{
          System.out.println("預存入多少金額:");
          BufferedReader Br = new BufferedReader(new InputStreamReader(System.in));
          String f = Br.readLine();
          m = Integer.parseInt(f);
          user[select].saveMoney(m);  
        }        
          
      }
      else if(action == 3)
      {
        /*int money;
        int m;
        System.out.println("需提出多少金額:");
        BufferedReader Bm = new BufferedReader(new InputStreamReader(System.in));
        String g = Bm.readLine();
        int m = money;
        money -= Integer.parseInt(g);
        System.out.println("餘額為:" + m +); */
      }
          
      else if(action == 4)
      {
        int number = 0;
        int inputBuf;
        String IDNO;
        System.out.println("可使用的帳號編號:");
        for(number = 0; number < index; number++)
        {
          System.out.println("編號 : " + number + " 帳號名稱 : " + user[number].account + "餘額 : " + user[number].showMoney());
        }
        number = 0;
        System.out.println("輸入欲查詢的帳號編號 : ");
        BufferedReader Buff = new BufferedReader(new InputStreamReader(System.in));
        String num = Buff.readLine();
        inputBuf = Integer.parseInt(num);  
        if(inputBuf > number)
        {
          System.out.println("輸入編號錯誤");  
        }
        else
          user[number].showMoney();
      }
      else if(action == -1);
      else
      {
        System.out.println("輸入錯誤");
      }
    }
 
    
  }
}


它顯示 2個錯誤 可以請大大給我指示 我該如何修改嗎
java:25:cannot return a value from method whose result type is void return this.money;

java:100:'void' type not allowed here
System.out.println("編號:" + number + "帳號名稱:" + user[number].account + "餘額:" +user[number].showMoney());


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
675 求救~~~~存款機的bug rusilent 3218 2010-03-30 19:50
593 Re:求救~~~~存款機的bug andreas_lin 155 2010-03-30 21:37
601 Re:求救~~~~存款機的bug motomoto 9 2010-03-30 22:09
614 Re:求救~~~~存款機的bug vincent_hwu 419 2010-03-30 22:38
» JWorld@TW »  Java 新手區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8