import java.util.Date; public class OrderRecord { public OrderRecord(String idCode, Food food, Customer customer, DeliveryMan deliveryMan, Date creationDate) { this.idCode = idCode; this.food = food; this.customer = customer; this.deliveryMan = deliveryMan; this.creationDate = creationDate; } private String idCode; private Food food; private Customer customer; private DeliveryMan deliveryMan; private Date creationDate; public String getIdCode() { return idCode; } public Food getFood() { return food; } public Customer getCustomer() { return customer; } public DeliveryMan getDeliveryMan() { return deliveryMan; } public Date getCreationDate() { return creationDate; } public void setIdCode(String idCode) { this.idCode = idCode; } public void setFood(Food food) { this.food = food; } public void setCustomer(Customer customer) { this.customer = customer; } public void setDeliveryMan(DeliveryMan deliveryMan) { this.deliveryMan = deliveryMan; } public void setCreationDate(Date creationDate) { this.creationDate = creationDate; } public String toString() { return "OrderRecord idCode: " + idCode + "\n food:" + food.getName() + "\n price:" + food.getPrice() + " RMB\n customer:" + customer + "\n deliveryMan: " + deliveryMan.toString() + "\n creationDate:" + creationDate; } }
时间: 2024-03-29 17:42:08 浏览: 129
java.util.Date与java.sql.Date的区别
这是一个Java类,名为OrderRecord,包含了一些属性和方法。该类表示订单记录,记录了客户购买的食品、配送员、创建时间等信息。
其中,构造方法OrderRecord()用于初始化订单记录的各个属性,包括订单号、食品、顾客、配送员、创建时间。getIdCode()、getFood()、getCustomer()、getDeliveryMan()、getCreationDate()方法用于获取各个属性的值。setIdCode()、setFood()、setCustomer()、setDeliveryMan()、setCreationDate()方法用于设置各个属性的值。toString()方法用于返回该订单记录的字符串表示形式,包括订单号、食品名称、价格、顾客信息、配送员信息和创建时间。
总的来说,该类可以用于表示订单记录,并且提供了一些方法用于设置和获取订单信息。
阅读全文