| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 396 人关注过本帖
标题:这个看不懂 能否帮我注解一下
只看楼主 加入收藏
mohuoo
Rank: 2
等 级:论坛游民
帖 子:10
专家分:11
注 册:2009-10-20
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:2 
这个看不懂 能否帮我注解一下
// 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
流星雨
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:JAVA风暴
等 级:版主
威 望:43
帖 子:1854
专家分:1868
注 册:2004-5-30
收藏
得分:20 
从键盘输入相宜的选项(("(B)alance (D)eposit (W)ithdraw (Q)uit:)
程序进行判断,分别对不同的选项调用不同的功能。

感谢你们带我找到星空下美丽神话,无论经历多少苦痛也不放弃的梦;插上希望翅膀乘风我和你们飞翔,飞过海天尽头携手把梦想实现.....
2009-10-21 12: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.034777 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved