Account

package com.hanqi.test;

public class Account {

private String zhanghao;private double yve;

Account (String z,double c)

{

zhanghao=z;

yve+=c;

}

Account (String z)

{

zhanghao=z;

}

void cunkuan(double c)

{

yve+=c;

System.out.println("存款:"+c);

}

boolean qukuan(double q)

{

if(q<=yve)

{

yve-=q;

System.out.println("取款:"+q);

return true;

}

else

{

System.out.println("余额不足");

return false;

}

}

double getYve()

{

return yve;

}

void Show()

{

System.out.println(zhanghao);

System.out.println(yve);

}

}

主类

package com.hanqi.test;

public class Bank {

public static void main(String[] args) {
Account a=new Account("11234564811231",5000);
a.cunkuan(200);
a.qukuan(3000);
a.qukuan(3000);
a.getYve();
a.Show(); }

}

存款:200.0

取款:3000.0

余额不足

11234564811231

2200.0

04-14 04:18