查看“Java MVC之用到的实体类”的源代码
←
Java MVC之用到的实体类
跳转至:
导航
,
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
==用户类:User== <nowiki>package entity; import service.*; public class User { private String id; //用户登录账号 private String name; //用户名-真实姓名 private String password;//用户登录密码 /** * 无参构造函数 */ public User() { } /** * 带参构造函数 * * * @param name * @param password */ public User(String name, String password) { this(); this.name = name; this.password = password; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "用户编号:" + this.id + " | 用户姓名:" + this.name; } } </nowiki> ==商品类:Goods== <nowiki>package entity; public class Goods { protected String id; //商品编号 protected String name; //商品名称 protected int number; //商品库存 protected float price; //商品价格 protected Tag tag; // 书籍详细分类(类目) public Goods(){} public Goods(String id,String name,float price,int number){ this.id = id; this.name = name; this.number = number; this.price = price; } public Goods(String id, String name, float price, int number,Tag tag) { this.id = id; this.name = name; this.number = number; this.price = price; this.tag = tag; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getNumber() { return number; } public void setNumber(int number) { this.number = number; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } public Tag getTag() { return tag; } public void setTag(Tag tag) { this.tag = tag; } @Override public String toString() { return "Goods [id=" + id + ", name=" + name + ", number=" + number + ", price=" + price +"tag="+tag+ "]"; } } </nowiki> ==商品标签类:Tag== <nowiki>package entity; public class Tag { private int id = 0; //商品一级类目 private String firstLevel; //商品二级类目 private String secondLevel; /* * 无参构造函数 */ public Tag() {} /* * 带三个参数的构造函数 */ public Tag(int id, String firstLevel, String secondLevel) { this.id = id; this.firstLevel = firstLevel; this.secondLevel = secondLevel; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getFirstLevel() { return firstLevel; } public void setFirstLevel(String firstLevel) { this.firstLevel = firstLevel; } public String getSecondLevel() { return secondLevel; } public void setSecondLevel(String secondLevel) { this.secondLevel = secondLevel; } @Override public String toString() { return this.firstLevel + ">" + this.secondLevel; } } </nowiki> ==商品子类:Book类== <nowiki>package entity; public class Book extends Goods{ String author; // 书籍作者 public Book() { } public Book(String cid, String name, int number,float price) { super(cid, name, price, number); } public Book(String cid, String name, String author, float price, int number,Tag tag) { super(cid, name,price,number,tag); this.author = author; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } @Override public String toString() { return "商品编号:" + this.id + " | 商品名:" + this.name + " | 商品总数:" + this.number+" |商品价格:"+this.price +" | 作者:" + this.author+ " | 类目:" + this.tag ; } }</nowiki> ==商品子类:Ipad类== <nowiki>package entity; public class Ipad extends Goods { private String model; // 平板电脑型号 public String getModel() { return model; } public void setModel(String model) { this.model = model; } public Ipad() { } public Ipad(String id, String name, float price, int number, String model, Tag tag) { super(id, name,price,number,tag); // this.model = model; } @Override public String toString() { return "商品编号:" + this.id + " | 商品名:" + this.name +" | 商品总数:" + this.number+" |商品价格:"+this.price +" | 型号:" + this.model+ "|商品分类:"+this.tag.toString(); } }</nowiki> 返回 [[Java程序设计]]
返回至
Java MVC之用到的实体类
。
导航菜单
个人工具
登录
命名空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息