模拟物流快递系统程序设计
【案例介绍】
1. 案例描述
网购已成为人们生活的重要组成部分,当人们在购物网站中下订单后,订单中的货物就会在经过一系列的流程后,送到客户的手中。而在送货期间,物流管理人员可以在系统中查看所有物品的物流信息。编写一个模拟物流快递系统的程序,模拟后台系统处理货物的过程。
2. 运行结果
【案例目标】
学会分析“模拟物流快递系统程序设计”任务实现的逻辑思路。
能够独立完成“模拟物流快递系统程序设计”的源代码编写、编译及运行。
掌握面向对象封装、继承和多态的概念和使用。
掌握抽象类和接口的使用。
废话不多说,我们直接上代码:
1.货物类
/**
* @function: 货物类
* @author: big
*/
public class cargo {
float mg; //货物质量
String odd; //快递单号
public float getMg() {
return mg;
}
public void setMg(float mg) {
this.mg = mg;
}
public String getOdd() {
return odd;
}
public void setOdd(String odd) {
this.odd = odd;
}
public cargo(float mg, String odd) {
this.mg = mg;
this.odd = odd;
}
@Override
public String toString() {
return "货物质量:" +getMg()+"Kg"+'\n'+
"货物检验完毕!" + '\n' +
"货物装填完毕!" + '\n' +
"运货人已通知!" + '\n' +
"快递单号:"+getOdd();
}
}
2.运货人类
/**
* @function: 运货人
* @author: big
*/
public class Person {
String name;
public Person(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
3.货车类
/**
* @function: 货车
* @author: big
*/
public class trucks {
String name;
String odd;
public String getOdd() {
return odd;
}
public String getName() {
return name;
}
public trucks(String name, String odd) {
this.name = name;
this.odd = odd;
}
}
4.坐标类
/**
* @function: 坐标
* @author: big
*/
public class xy {
int x;
int y;
public xy(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return x+","+y;
}
}
5.执行类
/**
* @function:执行类
* @author: big
*/
public class test {
public static void main(String[] args) {
System.out.println("订单开始处理,仓库验货中。。。。");
cargo c1=new cargo(76.34f,"HYX600235");
System.out.println(c1.toString());
System.out.println("==========================");
Person p1=new Person("小韩");
trucks t1=new trucks("大奔","z025");
System.out.println("运货人"+p1.getName()+"正在驾驶编号为"+t1.getOdd()+"的"+t1.getName()+"发送货物");
System.out.println("运输进行中。。。");
xy xy1=new xy(193,485);
System.out.println("货物当前坐标为:"+xy1.toString());
System.out.println("==========================");
System.out.println("所有运输任务已完成!");
System.out.println("运货人"+p1.getName()+"所驾驶的编号为"+t1.getOdd()+"的"+t1.getName()+"已经归还!");
System.out.println("货物运输车量保养完毕!");
}
}
如果能成功运行,请给博主点个赞!