本帖最后由 王渠 于 2012-5-4 12:54 编辑
- public class Account {
- private int id;
- private String name;
- private int balance;
- public void Account(){}
- public void Account (String name,int id,int balance)
- {
- this.id = id;
- this.name = name;
- this.balance = balance;
- }
- void withdraw(int money)
- {
- balance += money;
- }
- void deppsit(int money)
- {
- balance -=money;
- }
- public void Balance()
- {
- System.out.println("当前余额为"+balance);
- }
- }
复制代码- public class Test {
-
- public static void main (String args[]) {
- //Account p = new Account ();
- Account p = new Account ("刘玉",1105,20000);
- p.deppsit(2500);
- p.withdraw(30000);
- p.Balance();
- }
- }
复制代码 有空的构造函数,但是就是会提示好不到符号,构造函数,Account |