20180919_java_第七次_郑舒啸


public class Account {
    //属性
    private long id;
    private double balance;
    private String password;
    //get/set方法
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    public double getBalance() {
        return balance;
    }
    public void setBalance(double balance) {
        this.balance = balance;
    }
    public String getPassword() {
        return null;
    }
    public void setPassword(String password) {
        if(password.length()<6||password.length()>6)
        {
            System.out.println("新密码不符合规定,请重新设置");
        }
        else
        {
        this.password = password;
        }
    }
    //构造方法
    Account(){}
    Account(long id,double balance,String password)
    {
        this.id=id;
        this.balance=balance;
        this.password=password;
    }
    Account(Account acc)
    {
        this.id=acc.id;
        this.balance=acc.balance;
        this.password=acc.password;
    }
    
}
 

 

public class CreditAccount {
    //属性:信用额度
    private double creditLine;

    //get/set方法
    public double getCreditLine() {
        return creditLine;
    }

    public void setCreditLine(double creditLine) {
        this.creditLine = creditLine;
    }

    //构造方法
    CreditAccount(){}
    CreditAccount(double creditLine)
    {
        this.creditLine=creditLine;
    }
    CreditAccount(CreditAccount cre)
    {
        this.creditLine=cre.creditLine;
    }
}

 

 

public class SavingAccount {
    //属性:存款利率
    private double interestRate;

    //get/set方法
    public double getInterestRate() {
        return interestRate;
    }

    public void setInterestRate(double interestRate) 
    {
        if(interestRate>0 && interestRate<0.1)
        {
            this.interestRate = interestRate;
        }
        else
        {
            System.out.println("修改的新利率不符合规定,请重新设置");
        }
    }
    
    //构造方法
    SavingAccount(){}
    SavingAccount(double interestRate)
    {
        this.interestRate=interestRate;
    }
    SavingAccount(SavingAccount save)
    {
        this.interestRate=save.interestRate;
    }
}

转载于:https://my.oschina.net/u/3959935/blog/2104658

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值