赞
踩
网购已成为人民生活的重要组成部分,当人们在购物网站中下订单后,订单中的货物就会在经过一系列的流程后,送到客户手中。而在送货其间,物流管理人员可以在系统中查看所有物品的物流信息。编写一个模拟物流快递系统的程序,模拟后台系统处理货物的过程。
1)定义交通工具抽象类(jiaotonggongju),包含运输工具类型(leixing),承运商信息(chengyunshang),交通工具编号(num)
2)定义交通工具子类(jtgjzilei),包含运输工具类型(leixing),承运商信息(chengyunshang),交通工具编号(num),继承交通工具抽象父类,并对交通工具抽象类进行重写,
3)定义快递属性类和抽象方法,快递属性类(kuaidi),包含快递重量(weight),快递单号(ID),发货地点(place),抽象方法包含运送前,运送中,运送后。
4)定义测视类,通过调用交通工具子类、快递属性类、抽象方法和scanner函数,完成整个物流模拟快递系统的设计。
- //定义交通工具类(类型、承运商、号码)
-
- package project1;
-
- import java.security.PublicKey;
-
- public abstract class jiaotonggongju {
- private String leixing;
- private String chengyunshang;
- private String num;
-
- public jiaotonggongju() {
-
- }
-
- public jiaotonggongju(String leixing,String chengyunshang,String num){
- super();
- this.leixing=leixing;
- this.chengyunshang=chengyunshang;
- this.num=num;
- }
-
- public abstract void gongju();
-
- public String getNum() {
- return num;
- }
-
- public void setNum(String num) {
- this.num=num;
- }
-
- public String getLeixing() {
- return leixing;
- }
-
- public void setLeixing(String leixing) {
- this.leixing=leixing;
- }
-
- public String getChengyunshang() {
- return chengyunshang;
- }
-
- public void setChengyunshang(String chengyunshang) {
- this.chengyunshang=chengyunshang;
- }
- }
- //定义交通工具子类
-
- package project1;
-
- public class jtgjzilei extends jiaotonggongju {
- public jtgjzilei() {
- super();
- }
- public jtgjzilei(String leixing,String chengyunshang,String num) {
- super(leixing,chengyunshang,num);
- }
- public void gongju() {
- System.out.println("正在运输中......");
- }
-
- }
- //定义快递属性类和抽象方法
-
- package project1;
-
- import javax.crypto.interfaces.DHPublicKey;
-
- public class kuaidi {
- double weight;
- String ID;
- String place;
-
- public kuaidi(){
-
- }
-
- public kuaidi(double weight,String ID,String place) {
- super();
- this.weight=weight;
- this.ID=ID;
- this.place=place;
- }
-
- //运送前
-
- public void before() {
- System.out.println("订单开始处理");
- System.out.println("快递单号:"+this.ID);
- System.out.println("货物重量:"+this.weight+"kg");
- System.out.println(this.place+"仓库接货");
- System.out.println("仓库拣货");
- System.out.println("拣货完毕");
- System.out.println("已到达配送站,随机分配运货人");
- System.out.println("快件准备派送......");
- }
-
- //运输工具(交通工具子类)
-
- jtgjzilei tool=new jtgjzilei("汽车","顺丰快递","0328");
-
- //运送中
-
- public void ing() {
- System.out.println("承运商:"+tool.getChengyunshang()+"\n"+"编号:"+tool.getNum()+"\n"+"运送工具:"+ tool.getLeixing());
- tool.gongju();
- }
-
- //运送后
-
- public void later() {
- System.out.println("快件已签收");
- System.out.println("承运商"+tool.getChengyunshang()+"派送完毕");
- }
- }
- //测试类
-
- package project1;
-
- import java.util.Scanner;
-
- public class Test {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- kuaidi express=new kuaidi();
- System.out.println("正在创建快递项目");
- System.out.println("请输入快递重量:");
- express.weight=scanner.nextDouble();
- System.out.println("请输入快递单号:");
- express.ID=scanner.next();
- System.out.println("请输入发货地点:");
- express.place=scanner.next();
-
-
- //调用运送前
-
- System.out.println("\n");
- express.before();
- System.out.println("\n");
-
- //调用运送中
-
- express.ing();
- System.out.println("\n");
-
- //调用运送后
-
- express.later();
- System.out.println("\n");
-
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。