public class Product { private String spID; private String spName; private double spPrice; private String spDesc; private int spKucun; private LocalDateTime spTime;

public Product() {}

public Product(String spID, String spName, double spPrice, String spDesc, int spKucun, LocalDateTime spTime) {
    this.spID = spID;
    this.spName = spName;
    this.spPrice = spPrice;
    this.spDesc = spDesc;
    this.spKucun = spKucun;
    this.spTime = spTime;
}

public String getSpID() {
    return spID;
}

public void setSpID(String spID) {
    this.spID = spID;
}

public String getSpName() {
    return spName;
}

public void setSpName(String spName) {
    this.spName = spName;
}

public double getSpPrice() {
    return spPrice;
}

public void setSpPrice(double spPrice) {
    this.spPrice = spPrice;
}

public String getSpDesc() {
    return spDesc;
}

public void setSpDesc(String spDesc) {
    this.spDesc = spDesc;
}

public int getSpKucun() {
    return spKucun;
}

public void setSpKucun(int spKucun) {
    this.spKucun = spKucun;
}

public LocalDateTime getSpTime() {
    return spTime;
}

public void setSpTime(LocalDateTime spTime) {
    this.spTime = spTime;
}

public void info() {
    System.out.println("商品编号:" + spID);
    System.out.println("商品名称:" + spName);
    System.out.println("商品价格:" + spPrice);
    System.out.println("商品描述:" + spDesc);
    System.out.println("商品库存:" + spKucun);
    System.out.println("商品上架时间:" + spTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
}
3 创建商品实体类:Product1	定义属性:①	商品编号:spID②	商品名称 spName③	商品价格:spPrice④	商品描述:spDesc⑤	商品库存:spKucun⑥	商品上架时间:spTime2	对属性进行封装3	构造方法1:无参4	构造方法2:有参-所有属性5	定义方法:info——格式输出商品的基本信息

原文地址: https://www.cveoy.top/t/topic/hq2S 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录