复制
收藏
提问
全网

abstract class Transportation{//定义抽象的Transportation类 private String number;//交通工具的编号 private String model;//交通工具的型号 private String carrier;//交通工具的货运人 public Transportation() { super(); } public Transportation(String number,String model,String carrier) { this.number=number; this.model=model; this.carrier=carrier; } public String getNumber() { return number; } public String getModel() { return model; } public String getCarrier() { return carrier; } abstract void transport();//定义抽象的运输方法 } interface Maintainable//定义Maintainable接口 { public void maintenance();//定义抽象方法 } class Truck extends Transportation implements Maintainable//定义Truck类,该类继承Transportation类,并实现Maintainable接口 { public Truck() { super(); } public Truck(String number,String model,String carrier) { super(number, model, carrier);//调父类中的元素 } public void transport() { System.out.println("运输中......"); } public void maintenance() { System.out.println("货物运输车辆保养完毕"); } } interface GPS//定义GPS接口,包含定位功能 { public String showCoordinate(); } class Phone implements GPS//定义Phone类,并实现GPS接口 { public String showCoordinate() { String location="188°88,88°8"; return location; } } class Delivery//定义Delivery类 { private String deliveryID;//快递单号 private double weight;//货物重量 public Delivery(String deliveryID,double weight) { this.deliveryID=deliveryID; this.weight=weight; } public String getDeliveryID() { return deliveryID; } public double getWeight(){ return weight; } public void sendBefore()//sendBefore(),货物发送前 { System.out.println("订单开始处理,仓库验货中......"); System.out.println("货物重量:"+getWeight()+"kg"); System.out.println("货物检验完毕"); System.out.println("货物填装完毕"); System.out.println("货运人已通知"); System.out.println("快递单号:"+getDeliveryID()); } public void send(Transportation t,GPS g)//send(t,g)方法,货物发送途中 { System.out.println("货运人"+t.getCarrier()+"正在驾驶编号为"+t.getNumber()+"的"+t.getModel()+"发送货物"); t.transport(); System.out.println("货物当前的坐标为:"+g.showCoordinate()); } public void sendAfter(Transportation t)//sendAfter(t)方法,货物送达后 { System.out.println("货物运输任务已完成!"); System.out.println("货运人"+t.getCarrier()+"所驾驶的编号为"+t.getNumber()+"的"+t.getModel()+"已归还"); } } //定义测试类 public class test { public static void main(String[] args){ Delivery del=new Delivery("HYX600888",888.8);//创建Delivery类的实例对象 del.sendBefore();//调用Delivery类的sendBefore()方法 System.out.println("========================================"); Truck car=new Truck("Z088","劳斯莱斯","小李");//创建Truck类的实例对象 Phone p=new Phone();//创建Phone类的实例对象 del.send(car,p);//调用Delivery类的send()方法 System.out.println("========================================"); del.sendAfter(car);//调用Delivery类的sendAfter()方法 car.maintenance();//调用Truck类的maintenance()方法 } }

可爱意念师
3天前
全网
文档
学术
百科
知识库
时间不限
自动

理解问题abstract class Transportation{//定义抽象的Transportation类 private String number;//交通工具的编号 private String model;//交通工具的型号 private String carrier;//交通工具的货运人 public Transportation() { super(); } public Transportation(String number,String model,String carrier) { this.number=number; this.model=model; this.carrier=carrier; } public String getNumber() { return number; } public String getModel() { return model; } public String getCarrier() { return carrier; } abstract void transport();//定义抽象的运输方法 } interface Maintainable//定义Maintainable接口 { public void maintenance();//定义抽象方法 } class Truck extends Transportation implements Maintainable//定义Truck类,该类继承Transportation类,并实现Maintainable接口 { public Truck() { super(); } public Truck(String number,String model,String carrier) { super(number, model, carrier);//调父类中的元素 } public void transport() { System.out.println("运输中......"); } public void maintenance() { System.out.println("货物运输车辆保养完毕"); } } interface GPS//定义GPS接口,包含定位功能 { public String showCoordinate(); } class Phone implements GPS//定义Phone类,并实现GPS接口 { public String showCoordinate() { String location="188°88,88°8"; return location; } } class Delivery//定义Delivery类 { private String deliveryID;//快递单号 private double weight;//货物重量 public Delivery(String deliveryID,double weight) { this.deliveryID=deliveryID; this.weight=weight; } public String getDeliveryID() { return deliveryID; } public double getWeight(){ return weight; } public void sendBefore()//sendBefore(),货物发送前 { System.out.println("订单开始处理,仓库验货中......"); System.out.println("货物重量:"+getWeight()+"kg"); System.out.println("货物检验完毕"); System.out.println("货物填装完毕"); System.out.println("货运人已通知"); System.out.println("快递单号:"+getDeliveryID()); } public void send(Transportation t,GPS g)//send(t,g)方法,货物发送途中 { System.out.println("货运人"+t.getCarrier()+"正在驾驶编号为"+t.getNumber()+"的"+t.getModel()+"发送货物"); t.transport(); System.out.println("货物当前的坐标为:"+g.showCoordinate()); } public void sendAfter(Transportation t)//sendAfter(t)方法,货物送达后 { System.out.println("货物运输任务已完成!"); System.out.println("货运人"+t.getCarrier()+"所驾驶的编号为"+t.getNumber()+"的"+t.getModel()+"已归还"); } } //定义测试类 public class test { public static void main(String[] args){ Delivery del=new Delivery("HYX600888",888.8);//创建Delivery类的实例对象 del.sendBefore();//调用Delivery类的sendBefore()方法 System.out.println("========================================"); Truck car=new Truck("Z088","劳斯莱斯","小李");//创建Truck类的实例对象 Phone p=new Phone();//创建Phone类的实例对象 del.send(car,p);//调用Delivery类的send()方法 System.out.println("========================================"); del.sendAfter(car);//调用Delivery类的sendAfter()方法 car.maintenance();//调用Truck类的maintenance()方法 } }

已完成理解abstract class Transportation{//定义抽象的Transportation类 private String number;//交通工具的编号 private String model;//交通工具的型号 private String carrier;//交通工具的货运人 public Transportation() { super(); } public Transportation(String number,String model,String carrier) { this.number=number; this.model=model; this.carrier=carrier; } public String getNumber() { return number; } public String getModel() { return model; } public String getCarrier() { return carrier; } abstract void transport();//定义抽象的运输方法 } interface Maintainable//定义Maintainable接口 { public void maintenance();//定义抽象方法 } class Truck extends Transportation implements Maintainable//定义Truck类,该类继承Transportation类,并实现Maintainable接口 { public Truck() { super(); } public Truck(String number,String model,String carrier) { super(number, model, carrier);//调父类中的元素 } public void transport() { System.out.println("运输中......"); } public void maintenance() { System.out.println("货物运输车辆保养完毕"); } } interface GPS//定义GPS接口,包含定位功能 { public String showCoordinate(); } class Phone implements GPS//定义Phone类,并实现GPS接口 { public String showCoordinate() { String location="188°88,88°8"; return location; } } class Delivery//定义Delivery类 { private String deliveryID;//快递单号 private double weight;//货物重量 public Delivery(String deliveryID,double weight) { this.deliveryID=deliveryID; this.weight=weight; } public String getDeliveryID() { return deliveryID; } public double getWeight(){ return weight; } public void sendBefore()//sendBefore(),货物发送前 { System.out.println("订单开始处理,仓库验货中......"); System.out.println("货物重量:"+getWeight()+"kg"); System.out.println("货物检验完毕"); System.out.println("货物填装完毕"); System.out.println("货运人已通知"); System.out.println("快递单号:"+getDeliveryID()); } public void send(Transportation t,GPS g)//send(t,g)方法,货物发送途中 { System.out.println("货运人"+t.getCarrier()+"正在驾驶编号为"+t.getNumber()+"的"+t.getModel()+"发送货物"); t.transport(); System.out.println("货物当前的坐标为:"+g.showCoordinate()); } public void sendAfter(Transportation t)//sendAfter(t)方法,货物送达后 { System.out.println("货物运输任务已完成!"); System.out.println("货运人"+t.getCarrier()+"所驾驶的编号为"+t.getNumber()+"的"+t.getModel()+"已归还"); } } //定义测试类 public class test { public static void main(String[] args){ Delivery del=new Delivery("HYX600888",888.8);//创建Delivery类的实例对象 del.sendBefore();//调用Delivery类的sendBefore()方法 System.out.println("========================================"); Truck car=new Truck("Z088","劳斯莱斯","小李");//创建Truck类的实例对象 Phone p=new Phone();//创建Phone类的实例对象 del.send(car,p);//调用Delivery类的send()方法 System.out.println("========================================"); del.sendAfter(car);//调用Delivery类的sendAfter()方法 car.maintenance();//调用Truck类的maintenance()方法 } }

展开阅读网页

快捷访问
https://System.out.println("快递单号:"+getDeliveryID
https://System.out.println("快递单号:"+getDeliveryID

URL信息确认:无

❌ 无法访问或识别URL内容

很抱歉,我无法访问或识别该URL的内容。可能的原因包括:

  1. URL可能不正确或已失效
  2. 网站可能暂时无法访问
  3. 网页内容可能需要特殊权限才能访问

建议:

  • 请检查URL是否正确
  • 稍后再试
  • 直接访问对应的URL
更专业一些
转笔记
专业
abstract class Transportation{//定义抽象的Transportation类 private String number;//交通工具的编号 private String model;//交通工具的型号 private String carrier;//交通工具的货运人 public Transportation() { super(); } public Transportation(String number,String model,String carrier) { this.number=number; this.model=model; this.carrier=carrier; } public String getNumber() { return number; } public String getModel() { return model; } public String getCarrier() { return carrier; } abstract void transport();//定义抽象的运输方法 } interface Maintainable//定义Maintainable接口 { public void maintenance();//定义抽象方法 } class Truck extends Transportation implements Maintainable//定义Truck类,该类继承Transportation类,并实现Maintainable接口 { public Truck() { super(); } public Truck(String number,String model,String carrier) { super(number, model, carrier);//调父类中的元素 } public void transport() { System.out.println("运输中......"); } public void maintenance() { System.out.println("货物运输车辆保养完毕"); } } interface GPS//定义GPS接口,包含定位功能 { public String showCoordinate(); } class Phone implements GPS//定义Phone类,并实现GPS接口 { public String showCoordinate() { String location="188°88,88°8"; return location; } } class Delivery//定义Delivery类 { private String deliveryID;//快递单号 private double weight;//货物重量 public Delivery(String deliveryID,double weight) { this.deliveryID=deliveryID; this.weight=weight; } public String getDeliveryID() { return deliveryID; } public double getWeight(){ return weight; } public void sendBefore()//sendBefore(),货物发送前 { System.out.println("订单开始处理,仓库验货中......"); System.out.println("货物重量:"+getWeight()+"kg"); System.out.println("货物检验完毕"); System.out.println("货物填装完毕"); System.out.println("货运人已通知"); System.out.println("快递单号:"+getDeliveryID()); } public void send(Transportation t,GPS g)//send(t,g)方法,货物发送途中 { System.out.println("货运人"+t.getCarrier()+"正在驾驶编号为"+t.getNumber()+"的"+t.getModel()+"发送货物"); t.transport(); System.out.println("货物当前的坐标为:"+g.showCoordinate()); } public void sendAfter(Transportation t)//sendAfter(t)方法,货物送达后 { System.out.println("货物运输任务已完成!"); System.out.println("货运人"+t.getCarrier()+"所驾驶的编号为"+t.getNumber()+"的"+t.getModel()+"已归还"); } } //定义测试类 public class test { public static void main(String[] args){ Delivery del=new Delivery("HYX600888",888.8);//创建Delivery类的实例对象 del.sendBefore();//调用Delivery类的sendBefore()方法 System.out.println("========================================"); Truck car=new Truck("Z088","劳斯莱斯","小李");//创建Truck类的实例对象 Phone p=new Phone();//创建Phone类的实例对象 del.send(car,p);//调用Delivery类的send()方法 System.out.println("========================================"); del.sendAfter(car);//调用Delivery类的sendAfter()方法 car.maintenance();//调用Truck类的maintenance()方法 } }
知识树
abstract class Transportation{//定义抽象的Transportation类 private String number;//交通工具的编号 private String model;//交通工具的型号 private String carrier;//交通工具的货运人 public Transportation() { super(); } public Transportation(String number,String model,String carrier) { this.number=number; this.model=model; this.carrier=carrier; } public String getNumber() { return number; } public String getModel() { return model; } public String getCarrier() { return carrier; } abstract void transport();//定义抽象的运输方法 } interface Maintainable//定义Maintainable接口 { public void maintenance();//定义抽象方法 } class Truck extends Transportation implements Maintainable//定义Truck类,该类继承Transportation类,并实现Maintainable接口 { public Truck() { super(); } public Truck(String number,String model,String carrier) { super(number, model, carrier);//调父类中的元素 } public void transport() { System.out.println("运输中......"); } public void maintenance() { System.out.println("货物运输车辆保养完毕"); } } interface GPS//定义GPS接口,包含定位功能 { public String showCoordinate(); } class Phone implements GPS//定义Phone类,并实现GPS接口 { public String showCoordinate() { String location="188°88,88°8"; return location; } } class Delivery//定义Delivery类 { private String deliveryID;//快递单号 private double weight;//货物重量 public Delivery(String deliveryID,double weight) { this.deliveryID=deliveryID; this.weight=weight; } public String getDeliveryID() { return deliveryID; } public double getWeight(){ return weight; } public void sendBefore()//sendBefore(),货物发送前 { System.out.println("订单开始处理,仓库验货中......"); System.out.println("货物重量:"+getWeight()+"kg"); System.out.println("货物检验完毕"); System.out.println("货物填装完毕"); System.out.println("货运人已通知"); System.out.println("快递单号:"+getDeliveryID()); } public void send(Transportation t,GPS g)//send(t,g)方法,货物发送途中 { System.out.println("货运人"+t.getCarrier()+"正在驾驶编号为"+t.getNumber()+"的"+t.getModel()+"发送货物"); t.transport(); System.out.println("货物当前的坐标为:"+g.showCoordinate()); } public void sendAfter(Transportation t)//sendAfter(t)方法,货物送达后 { System.out.println("货物运输任务已完成!"); System.out.println("货运人"+t.getCarrier()+"所驾驶的编号为"+t.getNumber()+"的"+t.getModel()+"已归还"); } } //定义测试类 public class test { public static void main(String[] args){ Delivery del=new Delivery("HYX600888",888.8);//创建Delivery类的实例对象 del.sendBefore();//调用Delivery类的sendBefore()方法 System.out.println("========================================"); Truck car=new Truck("Z088","劳斯莱斯","小李");//创建Truck类的实例对象 Phone p=new Phone();//创建Phone类的实例对象 del.send(car,p);//调用Delivery类的send()方法 System.out.println("========================================"); del.sendAfter(car);//调用Delivery类的sendAfter()方法 car.maintenance();//调用Truck类的maintenance()方法 } }
抽象类与接口在Java中的作用是什么?
Java中如何实现多态?
面向对象编程的基本原则有哪些?

以上内容由AI搜集生成,仅供参考

在线客服