Java基础案例教程———【任务4-2】模拟物流快递系统

一、任务描述:

 

二、运行结果:

 

三、实现思路:

1、首先建立快递订单

快递任务类:变量货物重量,快递单号;

                      送货前方法;

                      送货中方法:需要车辆,定位;

                      送货后方法;

 

2、交通工具抽象类:运货人,车辆编号,车辆型号,

                                   送货方法(抽象的,每种车的运输方法可能不同)

3、交通工具子类:实现交通工具,重写交通运输方法,

                                该子类需要保养;

4、保养接口:一个抽象的保养方法(在交通工具子类中重写)

5.、GPS接口:当前坐标

6 、GPS实现类phone: 具有定位功能的设备

7、测试类

 

四、实现代码:

用于实例化对象的父类:

         私有内部变量,

          添加构造方法,

           添加Get  , Set 方法

        子类中实现构造方法

抽象类:

          私有内部变量,

            两个构造方法,

             抽象方法,

            Get方法 Set方法

子类:两个构造方法,

            重写抽象方法

接口:都是抽象方法,没有方法体;

实现类:空参构造,重写方法

 

/**
 *@Title sendTask.java
 *@time 2019年6月14日 下午2:52:54
 *@author 
 *@version 1.0
 *@description 快递任务类:
 *货物重量
 *快递单号
 *送货前方法
 *送货中方法
 *送货后方法
 *
 *
 */
package taskExpressage;

public class SendTask {
	private double goodsWeight; // 货物重量
	private String number; // 快递单号

	// 无参构造函数
	public SendTask() {

	}

	// 有参构造函数
	public SendTask(double goodsWeight, String number) {
		this.goodsWeight = goodsWeight;
		this.number = number;
	}

	// 运送前的方法
	public void sendBefore() {
		System.out.println("订单开始处理:");
		System.out.println("货物重量:" + this.goodsWeight + "kg");
		System.out.println("货物检验完毕!");
		System.out.println("货物装填完毕!");
		System.out.println("运货人已通知!");
		System.out.println("快递单号:" + this.number);

	}

	// 运输中方法
	public void sending(Transpotation tr, GPS gp) {
		System.out.println("运货人 " + tr.getCarrier() + "正在驾驶编号为"
				+ tr.getNumber() + "的" + tr.getModel() + "发送货物");
		tr.transpotation();
		System.out.println("货物当前的坐标为" + gp.showCoordinates());

	}

	public void sendAfter(Transpotation tr) {
		System.out.println("运输任务已完成");
		System.out.println("运货人" + tr.getCarrier() + "所驾驶的编号为" + tr.getNumber()
				+ "的" + tr.getModel() + "已归还");

	}

}

 

/**
 *@Title Transpotation.java
 *@time 2019年6月14日 下午3:42:33
 *@author wangyue
 *@version 1.0
 *@description 交通工具抽象类
 */
package taskExpressage;

public abstract class Transpotation {
	private String carrier; // 运货人
	private String number; // 车辆编号
	private String model; // 车辆型号

	public Transpotation() {

	}

	public Transpotation(String carrier, String number, String model) {
		this.carrier = carrier;
		this.number = number;
		this.model = model;
	}

	// 送货方法
	public abstract void transpotation();

	public String getCarrier() {
		return carrier;
	}

       //GET,SET方法
	public void setCarrier(String carrier) {
		this.carrier = carrier;
	}

	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;
	}

}
/**
 *@Title ATranspotation.java
 *@time 2019年6月14日 下午4:22:21
 *@author wangyue
 *@version 1.0
 *@description 交通工具子类
 */
package taskExpressage;

public class ATranspotation extends Transpotation implements Careable {

	// 构造方法
	public ATranspotation() {
		super();

	}

	public ATranspotation(String carrier, String number, String model) {
		super(carrier, number, model);

	}

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

	}

	// 重写保养方法 implements Careable
	public void upKeep() {
		System.out.println("货物运输车辆保养完毕");

	}

}

/**
 *@Title Careable.java
 *@time 2019年6月14日 下午4:37:54
 *@author wangyue
 *@version 1.0
 *@description 定义保养接口
 */
package taskExpressage;
public interface Careable {
	public  abstract void upKeep();

}
/**
 *@Title GPS.java
 *@time 2019年6月14日 下午4:56:50
 *@author wangyue
 *@version 1.0
 *@description  定义GPS接口
 *
 */
package taskExpressage;

public interface GPS {
	// 显示坐标的方法
	public String showCoordinates();

}
/**
 *@Title Phone.java
 *@time 2019年6月14日 下午5:22:19
 *@author wangyue
 *@version 1.0
 *@description GPS实现类
 */
package taskExpressage;

public class Phone implements GPS {

	public Phone() {
		super();

	}

	@Override
	public String showCoordinates() {
		String location = "121.323";
		return location;
	}

}

 

/**
 *@Title test.java
 *@time 2019年6月14日 下午5:52:12
 *@author wangyue
 *@version 1.0
 *@description 测试类
 */
package taskExpressage;

public class test {
	public static void main(String[] args) {
		// 创建 快递任务对象
		SendTask sendTask = new SendTask(2.34, "190617");

		// 送货前
		sendTask.sendBefore();
		System.out.println("=============================");

		// 送货中
		ATranspotation tr = new ATranspotation("chenhao", "TB2572", "五菱宏光");
		Phone ph = new Phone();
		sendTask.sending(tr, ph);
		System.out.println("=============================");

		// 送货后
		sendTask.sendAfter(tr);
	}

}

 

  • 13
    点赞
  • 103
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
PDF陆地光伏(PV)模块-设计鉴定和型式认可-第2部分的测试程序是为了确保光伏模块的性能和可靠性,在建造和生产过程中符合规定的技术要求。测试程序通常包括以下几个方面: 首先是材料和元器件的测试。这包括对光伏模块中所使用的材料和元器件进行化学成分和物理特性的测试,确保它们符合相关的标准和规范。这可以保证光伏模块在不同的环境条件下具有良好的耐久性和稳定性。 接下来是光伏模块的电性能测试。这包括对光伏模块的开路电压、短路电流、最大功率和效率等关键参数进行测试。这些测试可以验证模块的功率输出是否满足设计要求,确保模块在实际使用中能够正常运行。 第三个方面是光伏模块的可靠性测试。这包括对模块在不同温度、湿度和光照条件下的性能进行测试,并进行长期的耐久性测试。这些测试可以评估光伏模块的使用寿命和稳定性,确保其能够在不同场景下稳定运行。 最后,还需进行光伏模块的安全性测试。这包括对模块的防火性能、电气安全性和机械安全性等进行测试。这些测试可以确保光伏模块在安装和使用过程中不会对人身安全和环境造成危险。 总之,PDF陆地光伏模块的测试程序是为了保证其在设计、生产和使用过程中的性能和质量。这些测试可以确保光伏模块的可靠性、安全性和稳定性,促进光伏技术的发展和应用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值