package 继承;public class Example5_1{public static void main(String[] args) {Telephone2 tel;tel = new Telephone2("TCL", "8309600", 100);tel.setRate(0.2);tel.setDialledTime(150);tel.display();tel.callCost();tel.recharge(50);}}class Telephone2{private String brand;private String number;private double dialledTime;private double rate;double balance;public Telephone2(String brand,String number, double balance){this.brand = brand;this.number = number;this.balance = balance;}public String getBrand(){return brand;}public void setBrand(String brand){this.brand = brand;}public String getNumber() {return number;}public void setNumber(String number) {this.number = number;}public double getDialledTime() {return dialledTime;}public void setDialledTime(double dialledTime) {this.dialledTime = dialledTime;}public double getRate() {return rate;}public void setRate(double rate) {this.rate = rate;}public double getBalance() {return balance;}public void recharge(double cost) {balance = balance + cost;System.out.println("冲值后的余额:" + balance);}public void callCost() {double callcost = dialledTime * rate;balance = balance - callcost;System.out.println("话费:" + callcost);System.out.println("余额:" + balance);}public void display() {System.out.println("电话品牌:" + brand + "电话号码:" + number);System.out.println("通话时间:" + dialledTime + "费率:" + rate);}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。