package com.hanqi.test;
//银行账号
public class account {
private String zhanghao;//账号
//私有余额
private double yue;//余额
//double cunkuan;
// double qukuan;
//构造方法=
//有参无返
account(String zh)
{
zhanghao=zh;
}
account(String zh,double ck)
{
zhanghao=zh;
yue+=ck;
}
//成员方法
void cunqian(double qk)
{
yue+=qk;
System.out.println("当前余额是:"+yue);
}
//成员方法
boolean qukuan(double qk)
{
if(qk<=yue)
{
yue-=qk;
System.out.println("余额为:"+yue);
return true;
}
else
{
System.out.println("余额不足");
return false;
}
}
void getYue()
{
System.out.println("账号是:"+zhanghao+"当前余额:"+yue);
}
}
package com.hanqi.test;
public class Test05 {
public static void main(String[] args) {
account ac=new account("234234", 1000);
ac.qukuan(1000);
ac.cunqian(200000);
ac.qukuan(2000000);
}
}