IDEA+Java控制台实现房屋信息管理系统
【摘要】
目录
一、系统介绍
1.开发环境
2.技术选型
3.系统功能
二、系统展示
1.登录系统
2.查询房屋信息
3.添加房屋信息
4.修改房屋信息
5.删除房屋信息
三、部分代码
BussinessService
LoginService
House
User
四、其他
1.其他系统实现
...
目录
一、系统介绍
1.开发环境
开发工具:IDEA2018.2
JDK版本:jdk1.8
2.技术选型
Java语言开发,使用ArrayList存储实体信息。使用Enum枚举类型存储账号信息,使用乐Switch函数来选择判断。
3.系统功能
1.系统登录登出
2.房屋信息的增删改查
二、系统展示
1.登录系统
2.查询房屋信息
3.添加房屋信息
4.修改房屋信息
5.删除房屋信息
三、部分代码
BussinessService
-
package service;
-
-
import common.Constant;
-
import common.Response;
-
import entity.House;
-
-
import java.util.ArrayList;
-
import java.util.List;
-
-
public class BussinessService {
-
-
private static List<House> bussinessList = new ArrayList<>();
-
-
static {
-
bussinessList.add(new House("1","湖北省","鄂州市","紫气东来","0101","100万"));
-
bussinessList.add(new House("2","甘肃省","定西市","和睦和美","0202","60万"));
-
bussinessList.add(new House("3","甘肃省","定西市","德善堂村","0303","888888万"));
-
}
-
-
// 查询
-
public Response query(String name){
-
if(name == null || "".equals(name)){
-
return new Response("error","编号为空");
-
}
-
for(House house : bussinessList){
-
if(name.equals(house.getId())){
-
return new Response("success","查询成功",house);
-
}
-
}
-
return new Response("error","未查到到此"+ Constant.MAIN_CLASS+",请重新输入:");
-
}
-
-
// 增加
-
public Response add(House house){
-
for(House h : bussinessList){
-
if(h.getId().equals(house.getId())){
-
return new Response("error","该"+Constant.MAIN_CLASS+"已存在。");
-
}
-
}
-
bussinessList.add(house);
-
return new Response("success",Constant.MAIN_CLASS+"添加成功。",house);
-
}
-
-
-
// 编辑
-
public Response checkProp(House house,String prop,String value){
-
if(prop == null || "".equals(prop)){
-
return new Response("error","属性为空。");
-
}
-
String[] props = {"id","province","city","name","number","price"};
-
switch (prop){
-
case "id":
-
house.setId(value);
-
break;
-
case "provuince":
-
house.setProvince(value);
-
break;
-
case "city":
-
house.setCity(value);
-
break;
-
case "name":
-
house.setName(value);
-
break;
-
case "number":
-
house.setNumber(value);
-
break;
-
case "price":
-
house.setPrice(value);
-
break;
-
default:
-
return new Response("error","该属性不存在。");
-
-
}
-
return new Response("success","编辑成功。");
-
}
-
-
// 删除
-
public Response delete(String name){
-
if(name == null || "".equals(name)){
-
return new Response("error",Constant.MAIN_CLASS+"编号为空。");
-
}
-
for(House house:bussinessList){
-
if(house.getId().equals(name)){
-
bussinessList.remove(house);
-
return new Response("success",Constant.MAIN_CLASS+"删除成功。");
-
}
-
}
-
return new Response("error",Constant.MAIN_CLASS+"不存在。");
-
}
-
}
LoginService
-
package service;
-
-
import common.Account;
-
import common.Response;
-
import entity.User;
-
-
import java.util.ArrayList;
-
import java.util.List;
-
-
public class LoginService {
-
-
private static List<User> userList = new ArrayList<>();
-
-
static {
-
userList.add(new User(Account.ADMIN.getUsername(),Account.ADMIN.getPassword()));
-
userList.add(new User(Account.USER1.getUsername(),Account.USER1.getPassword()));
-
userList.add(new User(Account.USER2.getUsername(),Account.USER2.getPassword()));
-
userList.add(new User(Account.USER3.getUsername(),Account.USER3.getPassword()));
-
}
-
-
public Response login(String username,String password){
-
if(username == null || "".equals(username)){
-
return new Response("error","用户名为空,请输入用户名。");
-
}
-
if(password == null || "".equals(password)){
-
return new Response("error","密码为空,请输入密码。");
-
}
-
for(User user : userList){
-
if(username.equals(user.getUsername()) && password.equals(user.getPassword())){
-
return new Response("success","登录成功!");
-
}
-
}
-
return new Response("error","用户名或密码输入错误,请检查并输入。");
-
}
-
}
House
-
package entity;
-
-
/**
-
* 房屋实体类
-
*/
-
public class House {
-
-
// 房子id
-
private String id;
-
// 小区省份
-
private String province;
-
// 小区城市
-
private String city;
-
// 小区名称
-
private String name;
-
// 房子楼号
-
private String number;
-
// 房子价格
-
private String price;
-
-
-
public House(String id,String province,String city,String name,String number,String price){
-
this.id = id;
-
this.province = province;
-
this.city = city;
-
this.name = name;
-
this.number = number;
-
this.price = price;
-
}
-
-
-
public String getId(){
-
return id;
-
}
-
-
public void setId(String id){
-
this.id = id;
-
}
-
-
public String getProvince() {
-
return province;
-
}
-
-
public void setProvince(String province) {
-
this.province = province;
-
}
-
-
public String getCity() {
-
return city;
-
}
-
-
public void setCity(String city) {
-
this.city = city;
-
}
-
-
public String getName() {
-
return name;
-
}
-
-
public void setName(String name) {
-
this.name = name;
-
}
-
-
public String getNumber() {
-
return number;
-
}
-
-
public void setNumber(String number) {
-
this.number = number;
-
}
-
-
public String getPrice() {
-
return price;
-
}
-
-
public void setPrice(String price) {
-
this.price = price;
-
}
-
-
@Override
-
public String toString() {
-
return "House{" +
-
"id='" + id + '\'' +
-
", province='" + province + '\'' +
-
", city='" + city + '\'' +
-
", name='" + name + '\'' +
-
", number='" + number + '\'' +
-
", price='" + price + '\'' +
-
'}';
-
}
-
}
User
-
package entity;
-
-
/**
-
* 用户实体类
-
*/
-
public class User {
-
-
private String username;
-
private String password;
-
-
public User(){
-
-
}
-
-
public User(String username,String password){
-
this.username = username;
-
this.password = password;
-
}
-
-
public String getUsername(){
-
return username;
-
}
-
-
public void setUsername(){
-
this.username = username;
-
}
-
-
public String getPassword(){
-
return password;
-
}
-
-
public void setPassword(String password){
-
this.password = password;
-
}
-
-
public String toString(){
-
return "User{"+
-
"username='"+username+'\''+
-
",password='"+password+'\''+
-
'}';
-
}
-
}
四、其他
1.其他系统实现
2.获取源码
请您私信我。
3.运行项目
直接导入项目,打开Main运行程序。
4.备注
如有侵权请联系我删除。
5.支持博主
如果您觉得此文章对您有帮助,请点赞加关注,祝您身心健康!
文章来源: blog.csdn.net,作者:水坚石青,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/helongqiang/article/details/127057622
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)