模擬物流快遞系統程序設計

ransoprtation.java 抽象方法類,包含交通工具信息和運輸貨物方法,
/* * 交通工具類 */

public abstract class Transoprtation { private String number; private String model; private String admin; public Transoprtation(){ } public Transoprtation(String number,String model,String admin){ this.model=model; this.number=number; this.admin=admin; } public abstract void transport(); 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; } }
Careable.java 保養接口
public interface Careable { /* * 定義保養接口,具有保養功能 */
public abstract void upKeep(); }

Ztransportation.java專用運輸車類java

/* * 定義專用車輛類,該類繼承了交通工具接口,並實現了保養接口, */

public class Ztransportation extends Transoprtation implements Careable{ public Ztransportation(){ } public Ztransportation(String number,String model,String admin){ super(number,admin,model); //指定調用父類中的參數
 } @Override//重寫保養方法
    public void upKeep() { // TODO Auto-generated method stub
        System.out.println("貨物運輸車輛保養完畢。。。"); } @Override//定義運輸方法
    public void transport() { // TODO Auto-generated method stub
        System.out.println("運輸進行中。。。"); } }

 

SendTask.java快遞任務類ide

 

public class SendTask { private String number; private double goodsWeigh; public SendTask(){ } public SendTask(String number,double goodsWeight){ this.number=number; this.goodsWeigh=goodsWeight; } //送前準備
    public void sendBefore(){ System.out.println("訂單開始處理,倉庫驗貨中。。。"); System.out.println("貨物重量"+goodsWeigh); System.out.println("貨物檢驗完畢!"); System.out.println("貨物裝填完畢。"); System.out.println("運貨人已通知。"); System.out.println("快遞單號"+number); } //發送貨物
    public void send(Transoprtation t,GPS tool){ System.out.println("運貨人。"+t.getAdmin()+"正在駕駛標號爲"+t.getNumber() +""+t.getModel()+"發送貨物"); t.transport(); String showCoordinate = tool.shuwCoordinate(); System.out.println("貨物當前座標爲"+showCoordinate); } //送後操做
    public void sendAfter(Transoprtation t){ System.out.println("貨物運輸任務已將完成"); System.out.println("運貨人"+t.getAdmin()+
                "所駕駛的標號爲"+t.getNumber()+
                ""+t.getModel()+"已經歸還"); } public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public double getGoodsWeigh() { return goodsWeigh; } public void setGoodsWeigh(double goodsWeigh) { this.goodsWeigh = goodsWeigh; } }

 

 

 

GPS.java 接口工具

public interface GPS { public String shuwCoordinate(); }
Phone.java 繼承GPS 
public class Phone implements GPS { public Phone(){ } @Override public String shuwCoordinate() { String location = "193.264"; return location; } }
 
 

Task02Test.java 測試類測試

public class Task02Test { public static void main(String[] args) { SendTask task = new SendTask("hxy660235",75.31); task.sendBefore(); System.out.println("=========================="); Ztransportation t = new Ztransportation("Z025","bmw","xiaoli"); Phone p = new Phone(); task.send(t, p); System.out.println("=========================="); task.sendAfter(t); t.upKeep(); } }

 

 

相關文章
相關標籤/搜索