📄 product.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.shopping.model;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Timestamp;import java.util.logging.Level;import java.util.logging.Logger;/** * * @author ruirui */public class Product implements java.io.Serializable{ int id; String name; public int getCategoryId() { return categoryId; } public void setCategoryId(int categoryId) { this.categoryId = categoryId; } public String getDescr() { return descr; } public void setDescr(String descr) { this.descr = descr; } public int getId() { return id; } public void setId(int id) { this.id = id; } public double getMemberPrice() { return memberPrice; } public void setMemberPrice(double memberPrice) { this.memberPrice = memberPrice; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getNormalPrice() { return normalPrice; } public void setNormalPrice(double normalPrice) { this.normalPrice = normalPrice; } public Timestamp getPdate() { return pdate; } public void setPdate(Timestamp pdate) { this.pdate = pdate; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Product other = (Product) obj; if (this.name != other.name && (this.name == null || !this.name.equals(other.name))) { return false; } if (this.descr != other.descr && (this.descr == null || !this.descr.equals(other.descr))) { return false; } return true; } @Override public int hashCode() { int hash = 7; hash = 29 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 29 * hash + (this.descr != null ? this.descr.hashCode() : 0); return hash; } public void initRs(ResultSet rs){ try { this.setId(rs.getInt("id")); this.setName(rs.getString("name")); this.setDescr(rs.getString("descr")); this.setCategoryId(rs.getInt("categoryid")); this.setPdate(rs.getTimestamp("pdate")); this.setNormalPrice(rs.getDouble("normalprice")); this.setMemberPrice(rs.getDouble("memberprice")); } catch (SQLException ex) { Logger.getLogger(Product.class.getName()).log(Level.SEVERE, null, ex); } } String descr; double normalPrice; double memberPrice; Timestamp pdate; int categoryId; //这个产品属于哪一个类别, //保存一个引用很有必要 //我们在创建product 时一并初始化produt... //看productlist.jsp //后台的方法 Category category; public Category getCategory() { return category; } public void setCategory(Category category) { this.category = category; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -