Bookstore Management System:
Project Practice Objectives:
1. Java Application Basic Analysis
2. Training the basic idea of object-oriented programming
3. Comprehensive application of Java basic design pattern
4. Master the basic design of layering and interface
5, the construction of a reasonable Java application package structure
6, the comprehensive application of JSE learning knowledge
7. Use the set frame rationally in the application
8, in the application of integrated use of swing common components
9, the basic performance layer of the implementation mechanism
10, IO flow and the basic operation of files
11, the development of good Java programming habits
12, cultivate the ability to debug Java programs, cultivate the ability to change the wrong
Project Functional Requirements:
1, can carry out the operation of the user registration, modify basic information, delete and query.
2. The basic information of the book can be added, deleted, modified and query operation.
3, can fill in the purchase list, a purchase order with a number of specific purchase information, purchase books must be books management inside already have;
4, can fill out a sales list, a sales list with a number of specific sales information, the sale of books must be in the book management has been, and the number of sales can not exceed the current number of inventory, sales and modify the inventory corresponding to the inventory of books.
5, you can view the inventory of the details, you can follow the conditions to find the specific book inventory value.
6, the permissions of the simplification, do a fixed authority control. To the user according to the module into different operating rights of personnel, ad hoc a user admin, you can operate all the functions.
Basic project design:
★ Architecture Design
Overall framework, module division
Module Division: User, book, purchase, sales and inventory of 5 modules
★ System Functional Structure Design
Specific function modules for each function module
★ Database Design
Project Framework Implementation: Sub-module, tiering, subcontracting, building applications
1, User management (User.txt)
Description: The type is an int, which is used to represent the type of operation user.
1--is represented as admin, you can do all the things
2--as the person who can manipulate the library module
3--expressed as the person who can operate the inbound module
4--is represented as the person who can manipulate the sales module
5--represented as the person who can manipulate the Inventory module
2. Book Management (Book.txt)
3, incoming management (InMain.txt)
4, Purchase detail management (InDetail.txt)
5. Sales Management (OutMain.txt)
6. Sales Detail Management (OutDetail.txt)
7. Inventory Management (Stock.txt)
Project Subcontract
first layer: according to the module
User module (users),
Books (book),
Incoming (in),
Sales (out),
Stock (Store)
second layer: According to the three-layer mode
Presentation layer (UI), logical layer (business), and Data Layer (DAO)
Usually add a Value object layer (VO)
third floor: divide according to the layer
Depending on the circumstances, such as the business and DAO in the form of iron triangle to build the child package, and the UI and VO do not need to delimit the molecular package.
Project Layering idea:
Not perfect, please continue to focus on this series (ii)
The following is part of the code: (A public class inside Util)
Cn.hncu.bookStore.util
Fileioutil.java:
Package cn.hncu.bookStore.util;
Import Java.io.File;
Import Java.io.FileInputStream;
Import java.io.FileNotFoundException;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import Java.io.ObjectInputStream;
Import Java.io.ObjectOutputStream;
Import java.util.ArrayList;
Import java.util.List;
Import Javax.swing.JOptionPane; /** * User's common data read Write class * @author Chen Haoxiang * * @version 1.0/public class Fileioutil {publicly Fileioutil () {}/** * from number According to the library read all the data and return to the * * @param filename (data table corresponding to the file name) * @param ee (passed over the type of generics!)
) * @return Records of all tables! */@SuppressWarnings ("unchecked")/voltage warning public static<e> list<e> readformfile (String filename,e ee) {LIST&L T
e> list = new arraylist<e> ();
Final file File = new file (fileName);
ObjectInputStream in =null; if (!file.exists ()) {Joptionpane.showmessagedialog (null, "the datasheet does not exist!)
");
return list;
try {in = new ObjectInputStream (fileName) (new FileInputStream);
try {list = (list<e>) in.readobject (); } catch (ClassNotFoundException e) {e.printstacktrace ();
} catch (FileNotFoundException e) {e.printstacktrace ();
catch (IOException e) {e.printstacktrace ();
}finally{if (in!=null) {try {in.close ();
catch (IOException e) {throw new RuntimeException ("Database shutdown failed");
}} return list; /** * Writes a list collection into the data file filename * * @param list (data set to be stored) * @param filename (file name to which file is written)/public static Voi
D write2file (list<object> List, String fileName) {objectoutputstream out = null;
try {out = new ObjectOutputStream (new FileOutputStream (FileName));
Out.writeobject (list);
catch (FileNotFoundException e) {e.printstacktrace ();
catch (IOException e) {e.printstacktrace ();
}finally{if (out!=null) {try {out.close ();
catch (IOException e) {throw new RuntimeException ("Database shutdown failed!");
}
}
}
}
}
Encapsulated User data:
Cn.hncu.bookStore.user.vo;
Usermodel.java
Package cn.hncu.bookStore.user.vo; /** * @author Chen Haoxiang * @version 1.0 * * * <br/> * Value object for saving user information <br/> * 1, Serializable <br/> * 2, privatization of all variable members, complement sett Er-getters Method <br/> * 3, Write Equals and Hashcode methods----with a primary key (UUID) Unique identification code <br/> * 4, tostring Method <br/> * 5, NULL parameter construction method <
br/> */public class Usermodel {private string uuid;//user unique identifier private string name;//user name private int type;//user type Private String pwd;//User password public Usermodel () {}/** * feature: Get uuid-user Unique identifier * * @return return the uuid-user's unique identity code/public
String Getuuid () {return UUID;
/** * Function: Set uuid-user Unique identification code * @param uuid-User Unique identification code-string type parameter/public void Setuuid (String uuid) {this.uuid = UUID;
/** * Function: Get user's username * @return---name-username */public String GetName () {return name;
/** * Function: Set user name * * @param name--user name, string parameter */public void SetName (string name) {this.name = name; /** * Features: * The user's type: * 1--as admin, you can do all of the * 2--said to be able to operate the book module of the staff * 3--said to be able to operate the purchase module of the personnel * 4--expressed as able to operate the Sales module personnel
* 5--is represented as the person who can manipulate the Inventory module * @return The type of user * * public int getType () {return type; /** * Features: Set the user's type: * 1--as admin, can do all the * 2--for the personnel who can operate the Library module * 3--said to be able to operate the purchase module of the personnel * 4--expressed as able to operate the sales module of the personnel * 5--said to be able to operate the inventory model
Block person * @param type--user type-int parameter/public void SetType (int type) {this.type = type;
/** * Function: Get the user's password * @return string, the user's password */public string getpwd () {return pwd;
/** * Function: Set user password * @param pwd--string parameter/public void setpwd (String pwd) {this.pwd = pwd;
@Override public int hashcode () {final int prime = 31;
int result = 1;
result = Prime * result + ((uuid = null) 0:uuid.hashcode ());
return result;
@Override public boolean equals (Object obj) {if (this = obj) return true;
if (obj = null) return false;
if (GetClass ()!= Obj.getclass ()) return false;
Usermodel other = (Usermodel) obj;
if (uuid = null) {if (other.uuid!= null) return false;
else if (!uuid.equals (Other.uuid)) return false;
return true;
} @Override Public String toString () {return "Usermodel [uuid= + uuid +", name= "+ name +", type= "+ Type +", pwd= "+ pwd +"
]";
}
}
Encapsulated user query data:
Cn.hncu.bookStore.user.vo;
Userquerymodel.java
Package cn.hncu.bookStore.user.vo;
public class Userquerymodel extends usermodel{
}
Although this class has nothing, just inherited the Usermodel, but still must write, this is everyone to comply with the Java writing specifications!
User DAO (Data Layer): (interface)
Cn.hncu.bookStore.user.dao.dao;
Userdao.java
Package Cn.hncu.bookStore.user.dao.dao;
Import java.util.List;
Import Cn.hncu.bookStore.user.vo.UserModel;
Import Cn.hncu.bookStore.user.vo.UserQueryModel; /** * * @author Chen Haoxiang * * @version 1.0 * User module Data-layer interface/public interface Userdao {/** * feature: Create a user * * @param use
Rmodel---The user data to be created * @return---True to create success, false means create failure/public boolean create (Usermodel user); /** * Function: Delete a user * * @param UUID---User unique identification code, each user will not be the same * @return---True indicates that the deletion was successful, false means delete failed/public boolean delete (St
Ring UUID); /** * Function: Modify user Data * * @param user---Need to modify the username * @return return true-to indicate that the modification was successful, and return false-to indicate that the modification failed/public boolean update (U
Sermodel user);
/** * Function: To get all the user data * * @return---A usermodel set, that is, the user's data/public list<usermodel> getAll ();
/** * Function: According to a certain search conditions to find, * <br/> * to meet the search criteria to return the user data. * * @param UQM---Encapsulated lookup conditions * @return---User data set that satisfies the lookup criteria/public list<usermodel> getbycondition (Userquerymodel uqm
); /** * Function: To obtain a certain user's data information * * @param UUID---User Unique identification code * @return---Returns the subscriber data found by this unique identifier/public Usermodel Getsingle (String uuid);
}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.