模拟物流快递系统程序设计
package duixiang5;
public class Example18 {
public static void main ( String[ ] args) {
SendTask task= new SendTask ( "hyx600235" , 76.34 ) ;
task. sendBefore ( ) ;
System. out. println ( "----------" ) ;
ZTransportation t= new ZTransportation ( "2025" , "大奔" , "小韩" ) ;
Phone p= new Phone ( ) ;
task. send ( t, p) ;
System. out. println ( "------------" ) ;
task. sendAfter ( t) ;
t. upKeep ( ) ;
}
}
abstract class Transportation {
private String number;
private String model;
private String admin;
public Transportation ( ) {
super ( ) ;
}
public Transportation ( String number, String model, String admin) {
this . admin= admin;
this . model= model;
this . number= number;
}
public abstract void transport ( ) ;
public void setNumber ( String number) {
this . number= number;
}
public String getNumber ( ) {
return number;
}
public void setModel ( String model) {
this . model= model;
}
public String getModel ( ) {
return model;
}
public void setAdim ( String admin) {
this . admin= admin;
}
public String getAdmin ( ) {
return admin;
}
}
interface Careable {
public abstract void upKeep ( ) ;
}
class ZTransportation extends Transportation implements Careable {
public ZTransportation ( ) {
super ( ) ;
}
public ZTransportation ( String number, String model, String admin) {
super ( number, model, admin) ;
}
public void upKeep ( ) {
System. out. println ( "货物运输车保养完毕" ) ;
}
public void transport ( ) {
System. out. println ( "运输进行中---" ) ;
}
}
class SendTask {
private String number;
private double goodsWeight;
public SendTask ( ) {
super ( ) ;
}
public SendTask ( String number, double goodsWeight) {
this . goodsWeight= goodsWeight;
this . number= number;
}
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. transport ( ) ;
String showCoordinate= tool. showCoordinnate ( ) ;
System. out. println ( "货物当前坐标为:" + showCoordinate) ;
}
public void sendAfter ( Transportation t) {
System. out. println ( "货物运输任务已完成" ) ;
System. out. println ( "运货人" + t. getAdmin ( ) + "所驾驶的编号为" + t. getNumber ( )
+ "的" + t. getModel ( ) + "已归还" ) ;
}
public String getNumber ( ) {
return number;
}
public void setNumber ( String number) {
this . goodsWeight= goodsWeight;
}
public double getGoodsWeight ( ) {
return goodsWeight;
}
public void setGoodsEegiht ( double goodsWeight) {
this . goodsWeight= goodsWeight;
}
}
interface GPS {
public String showCoordinnate ( ) ;
}
class Phone implements GPS {
public Phone ( ) {
super ( ) ;
}
@Override
public String showCoordinnate ( ) {
String location= "193,485" ;
return location;
}
}