| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 396 人关注过本帖
标题:这个看不懂 能否帮我注解一下
取消只看楼主 加入收藏
mohuoo
Rank: 2
等 级:论坛游民
帖 子:10
专家分:11
注 册:2009-10-20
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:1 
这个看不懂 能否帮我注解一下
// Level 3 lab
package bank;
public class Teller {
    Account myAccount;
    public static void main (String args[]) {
    Teller me = new Teller();
    me.menu();
    }
    public Teller() {
    try {
        int count;
        byte inData[] = new byte[40];
        String inName;
        Double inMoney;
        System.out.print("Enter account name: ");
        count = System.in.read(inData);
        if (count == -1) {
        System.err.println("Error reading account name");
        System.exit(1);
        }
        inName = new String(inData,0,count-1);
        System.out.print("Enter amount to open account: ");
        count = System.in.read(inData);
        if (count == -1) {
        System.err.println("Error reading amount");
        System.exit(1);
        }
        inMoney = Double.valueOf(new String(inData,0,count-1));
        myAccount = new Account(inName,inMoney.doubleValue());
    } catch (Exception e) {
        System.err.println("Exception thrown:"+e.toString());
        System.exit(1);
    }
    }
    public void menu() {
    try {
        int key;
        byte inData[] = new byte[40];
        Double money;
        while(true) {
        System.out.print("(B)alance (D)eposit (W)ithdraw (Q)uit: ");
        key = System.in.read(inData);
        if (key == -1 ||
            (char)inData[0] == 'q' || (char)inData[0] == 'Q') {
            myAccount.print();
            System.exit(0);
        }
        if ((char)inData[0] == 'b' || (char)inData[0] == 'B') {
            myAccount.print();
        }
        if ((char)inData[0] == 'd' || (char)inData[0] == 'D') {
            System.out.print("Enter amount of deposit: ");
            key = System.in.read(inData);
            if (key != -1) {
            money = Double.valueOf(new String(inData,0,key-1));
            if (myAccount.deposit(money.doubleValue()) == 0) {
                System.out.println("Deposit has been made");
            } else {
                System.out.println("Problem with Deposit");
            }
            }
        }
        if ((char)inData[0] == 'w' || (char)inData[0] == 'W') {
            System.out.print("Enter amount of withdraw: ");
            key = System.in.read(inData);
            if (key != -1) {
            money = Double.valueOf(new String(inData,0,key-1));
            if (myAccount.withdraw(money.doubleValue()) == 0) {
                System.out.println("Withdraw has been made");
            } else {
                System.out.println("Problem with Withdraw");
            }
            }
        }
        }
    } catch (Exception e) {
        System.err.println("Exception thrown");
        System.exit(1);
    }
    }
}
搜索更多相关主题的帖子: 注解 
2009-10-21 11:06
mohuoo
Rank: 2
等 级:论坛游民
帖 子:10
专家分:11
注 册:2009-10-20
收藏
得分:0 
哦 谢谢 还能给我解释下 这段代码吗?
 public void menu() {
    try {
        int key;
        byte inData[] = new byte[40];
        Double money;
        while(true) {
        System.out.print("(B)alance (D)eposit (W)ithdraw (Q)uit: ");
        key = System.in.read(inData);
        if (key == -1 ||
            (char)inData[0] == 'q' || (char)inData[0] == 'Q') {
            myAccount.print();
            System.exit(0);
        }
        if ((char)inData[0] == 'b' || (char)inData[0] == 'B') {
            myAccount.print();
        }
        if ((char)inData[0] == 'd' || (char)inData[0] == 'D') {
            System.out.print("Enter amount of deposit: ");
            key = System.in.read(inData);
            if (key != -1) {
            money = Double.valueOf(new String(inData,0,key-1));
            if (myAccount.deposit(money.doubleValue()) == 0) {
                System.out.println("Deposit has been made");
            } else {
                System.out.println("Problem with Deposit");
            }
            }
        }
        if ((char)inData[0] == 'w' || (char)inData[0] == 'W') {
            System.out.print("Enter amount of withdraw: ");
            key = System.in.read(inData);
            if (key != -1) {
            money = Double.valueOf(new String(inData,0,key-1));
            if (myAccount.withdraw(money.doubleValue()) == 0) {
                System.out.println("Withdraw has been made");
            } else {
                System.out.println("Problem with Withdraw");
            }
            }
        }
        }
    } catch (Exception e) {
        System.err.println("Exception thrown");
        System.exit(1);
    }
    }
}
2009-10-21 12:32
快速回复:这个看不懂 能否帮我注解一下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018586 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved