java 程序注释
麻烦帮加下注释,自己看不懂classBankAccount{privateStringmyPassword;privatedoublemyBalance;privates...
麻烦帮加下注释,自己看不懂
class BankAccount
{
private String myPassword;
private double myBalance;
private static final double OD = 20.00;
public BankAccount()
{myPassword=""; myBalance = 0.0; }
public BankAccount(String pw , double bal)
{myPassword=pw; myBalance = bal; }
public double getBalance()
{ return myBalance; }
public void Deposit(String pw, double amt)
{ myPassword = pw ; myBalance += amt; }
public void Withdraw (String pw, double amt)
{myPassword = pw ;
if (myBalance < amt)
amt+=20;
myBalance -= amt;
}
}
public class Bank{
public static void main(String args[])
{
BankAccount Acc1 = new BankAccount();
System.out.println(Acc1.getBalance());
}
} 展开
class BankAccount
{
private String myPassword;
private double myBalance;
private static final double OD = 20.00;
public BankAccount()
{myPassword=""; myBalance = 0.0; }
public BankAccount(String pw , double bal)
{myPassword=pw; myBalance = bal; }
public double getBalance()
{ return myBalance; }
public void Deposit(String pw, double amt)
{ myPassword = pw ; myBalance += amt; }
public void Withdraw (String pw, double amt)
{myPassword = pw ;
if (myBalance < amt)
amt+=20;
myBalance -= amt;
}
}
public class Bank{
public static void main(String args[])
{
BankAccount Acc1 = new BankAccount();
System.out.println(Acc1.getBalance());
}
} 展开
5个回答
展开全部
* 银行账户碧返类
* 用于描述一个银行账悔芹饥户
* @see Bank
*
*/
class BankAccount {
/**
* 账户密码
*/
private String myPassword;
/**
* 账户余额
*/
private double myBalance;
private static final double OD = 20.00;
/**
* 默认构造方法
* 初始化密码为空,余额为0
*/
public BankAccount()
{
myPassword = "";
myBalance = 0.0;
}
/**
* 根据传入密码和余额构造银行账户
* @param pw 初始密码
* @param bal 初始余额首搜
*/
public BankAccount(String pw, double bal) {
myPassword = pw;
myBalance = bal;
}
/**
* 获取账户余额
* @return 账户余额
*/
public double getBalance() {
return myBalance;
}
/**
* 存款
* @param pw 账户密码
* @param amt 存入金额
*/
public void Deposit(String pw, double amt) {
myPassword = pw;
myBalance += amt;
}
/**
* 取款
* @param pw 账户密码
* @param amt 取出金额
*/
public void Withdraw(String pw, double amt) {
myPassword = pw;
//如果账户余额不足
if (myBalance < amt)
amt += 20;
myBalance -= amt;
}
}
/**
* 银行类
*/
public class Bank {
public static void main(String args[]) {
BankAccount Acc1 = new BankAccount();
System.out.println(Acc1.getBalance());
}
}
展开全部
class BankAccount//类定义名称
{
private String myPassword;//定义的字符串变量全局私有的(仅仅本类可以访问)
private double myBalance;//定义的双浮点数全局私有变岩物量
private static final double OD = 20.00;//定义静态final类型的
public BankAccount()//构造方法1
{myPassword=""; myBalance = 0.0; }
public BankAccount(String pw , double bal)//构造方法2,两个的区别是参数
{myPassword=pw; myBalance = bal; }
public double getBalance()//获得myBalance的值,私有的在非本类必须这样才能获得
{ return myBalance; }
public void Deposit(String pw, double amt)//自己定义的无返回方法,赋值密码和钱数加amt
{ myPassword = pw ; myBalance += amt; }
public void Withdraw (String pw, double amt)
{myPassword = pw ;
if (myBalance < amt)//判断大小,如果是myBalance <粗此液 amt这样的就执行下面的代码
amt+=20;//amt+20
myBalance -= amt;//myBalance-amt
}
}
public class Bank{//主类,文件名必须和这个一样Bank
public static void main(String args[])主方法格式规定是这样的args是输入参数数字字扒竖符串格式
{
BankAccount Acc1 = new BankAccount();//初始化这个类BankAccount (上面那个)
System.out.println(Acc1.getBalance());//获得myBalance的值,此时为0.0.执行的是构造方法1
}
}
{
private String myPassword;//定义的字符串变量全局私有的(仅仅本类可以访问)
private double myBalance;//定义的双浮点数全局私有变岩物量
private static final double OD = 20.00;//定义静态final类型的
public BankAccount()//构造方法1
{myPassword=""; myBalance = 0.0; }
public BankAccount(String pw , double bal)//构造方法2,两个的区别是参数
{myPassword=pw; myBalance = bal; }
public double getBalance()//获得myBalance的值,私有的在非本类必须这样才能获得
{ return myBalance; }
public void Deposit(String pw, double amt)//自己定义的无返回方法,赋值密码和钱数加amt
{ myPassword = pw ; myBalance += amt; }
public void Withdraw (String pw, double amt)
{myPassword = pw ;
if (myBalance < amt)//判断大小,如果是myBalance <粗此液 amt这样的就执行下面的代码
amt+=20;//amt+20
myBalance -= amt;//myBalance-amt
}
}
public class Bank{//主类,文件名必须和这个一样Bank
public static void main(String args[])主方法格式规定是这样的args是输入参数数字字扒竖符串格式
{
BankAccount Acc1 = new BankAccount();//初始化这个类BankAccount (上面那个)
System.out.println(Acc1.getBalance());//获得myBalance的值,此时为0.0.执行的是构造方法1
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-04-10
展开全部
class BankAccount
{
private String myPassword; //定义属性
private double myBalance; //定义属性
private static final double OD = 20.00; //定义属性并赋值
public BankAccount() //构造方法,给myPassword,myBalance赋值
{myPassword=""; myBalance = 0.0; }
public BankAccount(String pw , double bal)/戚仿神/构造方法
{myPassword=pw; myBalance = bal; }
public double getBalance() //myBalance的get方法
{ return myBalance; }
//方法
public void Deposit(String pw, double amt) {
myPassword = pw ; //把pw赋值给myPassword
myBalance += amt; //把amt每次加上自己赋值给myBalance
}
//方法
public void Withdraw (String pw, double amt) {
myPassword = pw ; //把pw赋值给myPassword
if (myBalance < amt) //对myBalance 进行判断,如果小于传来的amt值
amt+=20; //则amt自己加20
myBalance -= amt; //而myBalance等于自己减去高亏amt
}
}
public class Bank{
public static void main(String args[]) {
BankAccount Acc1 = new BankAccount(); //大森实例化BankAccount类 System.out.println(Acc1.getBalance()); //输出运行的getBalance方法
}
}
2楼的是网上拷贝的吧,连行数都没改掉
{
private String myPassword; //定义属性
private double myBalance; //定义属性
private static final double OD = 20.00; //定义属性并赋值
public BankAccount() //构造方法,给myPassword,myBalance赋值
{myPassword=""; myBalance = 0.0; }
public BankAccount(String pw , double bal)/戚仿神/构造方法
{myPassword=pw; myBalance = bal; }
public double getBalance() //myBalance的get方法
{ return myBalance; }
//方法
public void Deposit(String pw, double amt) {
myPassword = pw ; //把pw赋值给myPassword
myBalance += amt; //把amt每次加上自己赋值给myBalance
}
//方法
public void Withdraw (String pw, double amt) {
myPassword = pw ; //把pw赋值给myPassword
if (myBalance < amt) //对myBalance 进行判断,如果小于传来的amt值
amt+=20; //则amt自己加20
myBalance -= amt; //而myBalance等于自己减去高亏amt
}
}
public class Bank{
public static void main(String args[]) {
BankAccount Acc1 = new BankAccount(); //大森实例化BankAccount类 System.out.println(Acc1.getBalance()); //输出运行的getBalance方法
}
}
2楼的是网上拷贝的吧,连行数都没改掉
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-04-10
展开全部
这是一个模拟银行的。不过例子,只做了显示余额的功能演示。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你好,请下载,册纯如果有什么不懂的,可以姿脊追问的,或者联系我州册咐
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询