【案例4-8】模拟物流快递系统

网购已成为人们生活的重要组成部分,当人们在购物网站中下订单后,订单中的货物就会在经过一系列的流程后,送到客户的手中。而在送货期间,物流管理人员可以在系统中查看所有物品的物流信息。编写一个模拟物流快递系统的程序,模拟后台系统处理货物的过程。

此案例分为两个接口 Careable GPS和五个类 Phone SendTask Test Transportation ZTransprotation

Careable接口 

public interface Careable {
    public abstract void upKeep();
}

GPS接口

public interface GPS {
    public abstract String showGPS();
}

Phone 类

public class Phone implements GPS {

    @Override
    public String showGPS() {
        return "196,489";
    }
}

SendTask类

//快递任务类
public class SendTask {
private String number;
private double goodsWeight;

    public SendTask(String number, double goodsWeight) {
        this.number = number;
        this.goodsWeight = goodsWeight;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public double getGoodsWeight() {
        return goodsWeight;
    }

    public void setGoodsWeight(double goodsWeight) {
        this.goodsWeight = goodsWeight;
    }
    //发送前
    public void sendBefore(){
        System.out.println("订单开始处理,仓库验货。。。");
        System.out.println("货物重量"+this.getGoodsWeight()+"kg");
        System.out.println("货物检验完毕");
        System.out.println("货物装填完毕");
        System.out.println("运货人已通知");
        System.out.println("快递单号"+this.getNumber());
    }
    //发送
    public void send(Transportation t,GPS tool){
        System.out.println("运货人"+t.getAdmin()+"正在驾驶编号"+t.getNumber()+"的"+t.getModel()+"发送货物");
        t.transportation();
        System.out.println("货车当前坐标"+tool.showGPS());

    }
    //发送后
    public void send(Transportation t){
        System.out.println("货物运输任务完成");
        System.out.println("运货人"+t.getAdmin()+"所驾驶的编号为;"+t.getNumber()+"的"+t.getModel()+"已归还");

    }

    public void SendAfter(ZTransportation t) {
    }
}

Transportation 类

//运输工具类
public abstract class Transportation {
    private String number;//编号
    private String model;//型号
    private String admin;//负责人

    public Transportation(String number, String model, String admin) {
        this.number = number;
        this.model = model;
        this.admin = admin;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getAdmin() {
        return admin;
    }

    public void setAdmin(String admin) {
        this.admin = admin;
    }
    public abstract void transportation();
}

ZTransprotation类

public class ZTransportation extends Transportation implements Careable{
    public ZTransportation(String number, String model, String admin) {
        super(number, model, admin);
    }

    @Override
    public void upKeep() {
        System.out.println("运输完成,保养车辆。。。");

    }

    @Override
    public void transportation() {
        System.out.println("运输进行中。。。");
    }
}

Test类


public class Test {
    public static void main(String[] args) {
        SendTask task =new SendTask("TB1001",10);
        task.sendBefore();
        System.out.println("==========================");
        ZTransportation t =new ZTransportation("Z001","大奔","小韩");
        Phone p =new Phone();
        task.send(t,p);
        System.out.println("=======================");
        task.SendAfter(t);
        t.upKeep();
    }

}

结果展示

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

浩气长存在心中

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值