示例代码
package com.powernode.oo;
public class Order {
/**
* 名称
*/
private String name;
/**
* 订单标识
*/
private String productId;
/**
* 下单时间
*/
private String orderTime;
/**
* 付款时间
*/
private String paymentTime;
/**
* 支付状态
*/
private Boolean paymentStatus;
/**
* 用户ID
*/
private String userId;
/**
* 数量
*/
private int number;
/**
* 单价
*/
private int unitPrice;
public Order() {
}
public Order(String name, String productId, String orderTime, String paymentTime, Boolean paymentStatus, String userId, int number, int unitPrice) {
this.name = name;
this.productId = productId;
this.orderTime = orderTime;
this.paymentTime = paymentTime;
this.paymentStatus = paymentStatus;
this.userId = userId;
this.number = number;
this.unitPrice = unitPrice;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getOrderTime() {
return orderTime;
}
public void setOrderTime(String orderTime) {
this.orderTime = orderTime;
}
public String getPaymentTime() {
return paymentTime;
}
public void setPaymentTime(String paymentTime) {
this.paymentTime = paymentTime;
}
public Boolean getPaymentStatus() {
return paymentStatus;
}
public void setPaymentStatus(Boolean paymentStatus) {
this.paymentStatus = paymentStatus;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(int unitPrice) {
this.unitPrice = unitPrice;
}
}
测试代码
package com.powernode.oo;
/**
* @Author Zhaolei
* @Date 2022/11/10 21:42
* @Version 2020.1
*/
public class OrderTest {
public static void main(String[] args) {
/*
* 创建一个订单对象,并初始化订单实例变量
*/
Order order = new Order("娃哈哈", "001", "2021年9月22日15点55分32秒", "2021年9月22日15点55分32秒", true, "001", 555, 50);
System.out.println(order.getName());
System.out.println(order.getProductId());
System.out.println(order.getOrderTime());
System.out.println(order.getPaymentTime());
System.out.println(order.getPaymentStatus());
System.out.println(order.getUserId());
System.out.println(order.getNumber());
System.out.println(order.getUnitPrice());
order.setName("康师傅");
order.setProductId("002");
order.setOrderTime("2021年9月23日16点15分12秒");
order.setPaymentTime("2021年9月23日16点25分12秒");
order.setPaymentStatus(true);
order.setUserId("002");
order.setNumber(666);
order.setUnitPrice(20);
System.out.println("=========================================================");
System.out.println(order.getName());
System.out.println(order.getProductId());
System.out.println(order.getOrderTime());
System.out.println(order.getPaymentTime());
System.out.println(order.getPaymentStatus());
System.out.println(order.getUserId());
System.out.println(order.getNumber());
System.out.println(order.getUnitPrice());
}
}
测试结果