SoSo营业厅

//账户类

public class Account {
    private String type;//账户类型
    private String telNo;//电话号码
    private int money;//账户余额
    private String name;//用户名
    private String pwd;//密码
    private Taocan taocan;//套餐
     private int heji;//合计
     
    public int getHeji() {
        return heji;
    }
    public void setHeji(int heji) {
        this.heji = heji;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getTelNo() {
        return telNo;
    }
    public void setTelNo(String telNo) {
        this.telNo = telNo;
    }
    public int getMoney() {
        return money;
    }
    public void setMoney(int money) {
        this.money = money;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPwd() {
        return pwd;
    }
    public void setPwd(String pwd) {
        this.pwd = pwd;
    }
    public Taocan getTaocan() {
        return taocan;
    }
    public void setTaocan(Taocan taocan) {
        this.taocan = taocan;
    }
    public Account(String type, String telNo, int money, String name,
            String pwd, Taocan taocan) {
        super();
        this.type = type;
        this.telNo = telNo;
        this.money = money;
        this.name = name;
        this.pwd = pwd;
        this.taocan = taocan;
    }
    public Account() {
        super();
    }
    

}

//父类

public abstract class Taocan {
    private String type;//套餐类型 
    private int speakTime;// 通话时间;
    private int speakTimeLeft;// 剩余的通话时间;
    private int price;// 套餐费用
    private int flow; // 流量
    private int flowLeft;// 流量剩余
    private int text;// 短信条数
    private int textLeft;// 剩余短信条数
    private String recordes;//消费记录
   
    public String getRecordes() {
        return recordes;
    }

    public void setRecordes(String recordes) {
        this.recordes = recordes;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getSpeakTime() {
        return speakTime;
    }

    public void setSpeakTime(int speakTime) {
        this.speakTime = speakTime;
    }

    public int getSpeakTimeLeft() {
        return speakTimeLeft;
    }

    public void setSpeakTimeLeft(int speakTimeLeft) {
        this.speakTimeLeft = speakTimeLeft;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getFlow() {
        return flow;
    }

    public void setFlow(int flow) {
        this.flow = flow;
    }

    public int getFlowLeft() {
        return flowLeft;
    }

    public void setFlowLeft(int flowLeft) {
        this.flowLeft = flowLeft;
    }

    public int getText() {
        return text;
    }

    public void setText(int text) {
        this.text = text;
    }

    public int getTextLeft() {
        return textLeft;
    }

    public void setTextLeft(int textLeft) {
        this.textLeft = textLeft;
    }

    public Taocan(int speakTime, int price, int flow, int text) {
        this.speakTime = speakTime;
        this.price = price;
        this.flow = flow;
        this.text = text;
        

    }
    

    public Taocan() {
        super();
    }
    //打印信息
    public abstract void printInfo();
    //消费
    public void consume(String TelNo){
        
    }
}

//子类

import com.pt.test.Test;

public class NetTaocan extends Taocan{
//网虫套餐    
    public NetTaocan(){
        super.setSpeakTime(0);// 通话时间
        super.setPrice(68);//套餐费用
        super.setFlow(1024*5);//流量
        super.setText(0);//短信
        super.setType(“网虫套餐”);
        
    }

    @Override
    public void printInfo() {
        System.out.println(“网虫套餐: \r\n” + “上网流量:5GB\r\n” + “月资费:68元”);
        
    }
    public void consume(String TelNo){
        int choise = (int)(Math.random()*2);
        switch (choise) {
         
        case 1:
              useFlow(TelNo);
            break;

        default:
            break;
        }
    }
    
    private void useFlow(String telNo) {
        int money=0;//当前消费金额
        System.out.println(“使用流量3000”);
        if(this.getRecordes()!=null){
            this.setRecordes(this.getRecordes()+”  “+”使用流量3000”);
            
        }else{
            System.out.println(“使用流量1200”);
        }
        
        //剩余流量
        if(this.getFlow()-3000>=0){
            this.setFlow(this.getFlow()-3000);
            System.out.println(this.getFlow());
        }else{
            money=(1200-this.getFlow())*1;
            this.setFlow(0);
            for (int i = 0; i

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值