Java 0526 第六次课作业

答案:A

第六行:System.out.println(mc1.getValue());

第七行:System.out.println(mc2.getValue());

package org.jsoft.extend;

public class Account {
		private long id;
		private double balance;
		private String passworld;
		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 getPassworld() {				//密码get方法返回null
			return null;
		}
		public void setPassworld(String passworld) {//set方法只有密码长度为6时才能传参
			if(passworld.length()==6){
			this.passworld = passworld;
			}
		}	
		public void show(){
			System.out.println(passworld);
		}
}
package org.jsoft.extend;

class SavingAccount extends Account{
    private double interestRate;

    public double getInterestRate() {
        return interestRate;
    }

    public void setInterestRate(double interestRate) {	//set方法利率大于0小于0.1才能传参
        if(interestRate>0&&interestRate<0.1) {
            this.interestRate = interestRate;
        }
    }
}
package org.jsoft.extend;

class CreditAccount extends Account{
    private double cerditLine;

    public double getCerditLine() {
        return cerditLine;
    }

    public void setCerditLine(double cerditLine) {
        this.cerditLine = cerditLine;
    }
}
package org.jsoft.extend;

public class Test {

	public static void main(String[] args) {
		Account a = new Account();
		a.setPassworld("1234567");				//测试密码长度不正确
		System.out.println(a.getPassworld());	//测试get密码返回null
		a.show();
		SavingAccount s = new SavingAccount();
		s.setInterestRate(0.2);					//测试概率不正确
		System.out.println(s.getInterestRate());
	}

}

213528_81R4_3858331.png

转载于:https://my.oschina.net/u/3858331/blog/1819269

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值