java网上书城系统代码 网上书店java代码

基于java web的图书管理系统的设计与实现怎么写

第一步: 首先要确定你的开发框架, 比如springmvc+mybatis, 然后框架整合一下能跑通

成都创新互联公司专注于网站建设,为客户提供网站设计制作、做网站、网页设计开发服务,多年建网站服务经验,各类网站都可以开发,品牌网站设计,公司官网,公司展示网站,网站设计,建网站费用,建网站多少钱,价格优惠,收费合理。

第二步: 分析需求, 比如至少需要哪些模块, 诸如登录注册模块, 图书管理模块, 用户管理模块等等

第三步: 选择一个主题做前端, 然后实现你的mvc相关层的代码即可

如果不会的话可以look at my name, 肯定又符合你要求的项目

用java编写一个 图书馆图书借阅管理系统

---------------------------------------------------

给你修改了三个地方:

1.borrowBooks方法中,将System.out.println("你要借吗?"); 改为:

System.out.println("你要借吗?输入1表示借,其他数字表示不借。");

保证输入的时候输入的数字,否则会报出异常。

2.borrowBooks方法中,将self[score] = all[9]; 改为:self[score] = all[i];

如果是all[9],那么就始终是最后一本书籍信息了。

3.have方法中,你是想将所借的书籍信息都打印出来。修改的比较多,下面注释代码是原来的。

void have(Books[] self) {

// for (int i = 0; i 2; i++) {

// self[i].showBookInfo();

// }

for (int i = 0; i 3; i++) {

if(self[i]!=null)

self[i].showBookInfo();

}

}

****************** 附上所有代码:*************************

import java.util.Scanner;

public class TestBook {

public static void main(String[] args) {

Books all[] = new Books[10];

Books self[] = new Books[3];

all[0] = new Books("java", 1, "12345", "tom", 34.0f, "人民出版社");

all[1] = new Books("c", 2, "12346", "tnn", 31.0f, "人民出版社");

all[2] = new Books("c++", 3, "12445", "mm", 35.0f, "人民出版社");

all[3] = new Books("c#", 4, "12365", "tt", 38.0f, "人民出版社");

all[4] = new Books("j2se", 5, "13345", "tosm", 31.1f, "人民出版社");

all[5] = new Books("j2ee", 6, "18345", "ttm", 32.0f, "人民出版社");

all[6] = new Books("jsp", 7, "12335", "cc", 33.0f, "人民出版社");

all[7] = new Books("net", 8, "12341", "bb", 36.0f, "人民出版社");

all[8] = new Books("ip", 9, "12343", "aa", 37.0f, "人民出版社");

all[9] = new Books("tcp", 10, "22345", "jj", 39.0f, "人民出版社");

Readers r = new Readers("xiaoming", 101, "1", 3);

r.searchAllBooks(all);

r.borrowBooks(all, self);

r.have(self);

r.give(all, self);

}

}

class Readers {

Scanner scan = new Scanner(System.in);

String names;

int nums;

String classes;

int grade;

int score = 0;

// Books self[]=new Books[3];

Readers(String n, int u, String c, int g) {

names = n;

nums = u;

classes = c;

grade = g;

}

void searchAllBooks(Books[] all) {// 查书

for (int i = 0; i 10; i++)

all[i].showBookInfo();

// self[score]=all[0];

}

void give(Books[] all, Books[] self) {// 还书

System.out.println("请输入您要还的书的书号");

int n = scan.nextInt();

for (int i = 0; i 10; i++) {

if (n == all[i].num) {

for (int j = 0; j 3; j++) {

if (self[j] == all[i]) {

self[j] = null;

System.out.println("还书成功");

}

}

}

}

}

void have(Books[] self) {

// for (int i = 0; i 2; i++) {

// self[i].showBookInfo();

// }

for (int i = 0; i 3; i++) {

if(self[i]!=null)

self[i].showBookInfo();

}

}

void giveMoney() {

}

void borrowBooks(Books[] all, Books[] self) {

System.out.println("请输入您要查找的书名:");

String n = scan.next();

int i;

for (i = 0; i 10; i++) {

if (n.equals(all[i].name)) {

all[i].showBookInfo();

break;

}

}

//System.out.println("你要借吗?");

System.out.println("你要借吗?输入1表示借,其他数字表示不借。");

int j;

j = scan.nextInt();

if (j == 1) {

System.out.println("借阅成功");

//self[score] = all[9];

self[score] = all[i];

score += 1;

}

if (score 4) {

System.out.println("您还可以借阅" + (3 - score) + "本");

} else {

System.out.println("对不起,一个人只能借3本");

}

}

}

class Books {

String name;

int num;

String ISBN;

String writer;

float price;

String publisher;

Books(String n, int u, String i, String w, float p, String l) {

name = n;

num = u;

ISBN = i;

writer = w;

price = p;

publisher = l;

}

void showBookInfo() {

System.out.println("**************************");

System.out.println("书名:" + name);

System.out.println("索书号:" + num);

System.out.println("ISBN号:" + ISBN);

System.out.println("价格:" + price);

System.out.println("出版社:" + publisher);

System.out.println("**************************");

}

}

----------------------------------------------------

java图书管理界面系统的源代码

java swing 登陆界面code

/*

* Login.java

*

* Created on __DATE__, __TIME__

*/

package com.agen.library.window;

import java.awt.Image;

import java.awt.Toolkit;

import javax.swing.JOptionPane;

import javax.swing.UIManager;

import javax.swing.UnsupportedLookAndFeelException;

import com.agen.library.factory.DAOFactory;

import com.agen.library.util.GlobalUser;

import com.agen.library.vo.User;

/**

*

* @author __USER__

*/

public class Login extends javax.swing.JFrame {

/**

*

*/

private static final long serialVersionUID = -2176093732040600809L;

/** Creates new form Login */

public Login() {

super("易云图书管理软件V1.0");

Image ime = Toolkit.getDefaultToolkit().getImage(

getClass().getResource("/images/ico.png"));

try {

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (InstantiationException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IllegalAccessException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (UnsupportedLookAndFeelException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

setIconImage(ime);

initComponents();

setLocationRelativeTo(null);

this.setResizable(false);

}

/**

* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is always

* regenerated by the Form Editor.

*/

// GEN-BEGIN:initComponents

// editor-fold defaultstate="collapsed" desc="Generated Code"

private void initComponents() {

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField();

jPasswordField1 = new javax.swing.JPasswordField();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

jMenuBar1 = new javax.swing.JMenuBar();

jMenu1 = new javax.swing.JMenu();

jMenuItem1 = new javax.swing.JMenuItem();

jMenu2 = new javax.swing.JMenu();

jMenuItem2 = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

addKeyListener(new java.awt.event.KeyAdapter() {

public void keyPressed(java.awt.event.KeyEvent evt) {

formKeyPressed(evt);

}

public void keyTyped(java.awt.event.KeyEvent evt) {

formKeyTyped(evt);

}

});

jLabel2.setFont(new java.awt.Font("微软雅黑", 0, 14));

jLabel2.setText("\u7528\u6237\u540d\uff1a");

jLabel3.setFont(new java.awt.Font("微软雅黑", 0, 14));

jLabel3.setText("\u5bc6 \u7801\uff1a");

jTextField1.setFont(new java.awt.Font("微软雅黑", 0, 14));

jTextField1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jTextField1ActionPerformed(evt);

}

});

jPasswordField1.setFont(new java.awt.Font("微软雅黑", 0, 12));

jPasswordField1.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyTyped(java.awt.event.KeyEvent evt) {

jPasswordField1KeyTyped(evt);

}

});

jButton1.setBackground(new java.awt.Color(223, 216, 216));

jButton1.setFont(new java.awt.Font("微软雅黑", 0, 14));

jButton1.setText("\u767b\u9646");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

}

});

jButton2.setBackground(new java.awt.Color(223, 216, 216));

jButton2.setFont(new java.awt.Font("微软雅黑", 0, 14));

jButton2.setText("\u53d6\u6d88");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

}

});

jLabel1.setIcon(new javax.swing.ImageIcon(

getClass().getResource("/images/login_main.jpg"))); // NOI18N

jMenu1.setText("File");

jMenu1.setFont(new java.awt.Font("微软雅黑", 0, 14));

jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(

java.awt.event.KeyEvent.VK_Q,

java.awt.event.InputEvent.CTRL_MASK));

jMenuItem1.setText("Exit");

jMenuItem1.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jMenuItem1MouseClicked(evt);

}

});

jMenuItem1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem1ActionPerformed(evt);

}

});

jMenu1.add(jMenuItem1);

jMenuBar1.add(jMenu1);

jMenu2.setText("Help");

jMenu2.setFont(new java.awt.Font("微软雅黑", 0, 14));

jMenuItem2.setText("About");

jMenuItem2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem2ActionPerformed(evt);

}

});

jMenu2.add(jMenuItem2);

jMenuBar1.add(jMenu2);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(

getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(layout

.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel1)

.addGroup(

layout.createSequentialGroup()

.addContainerGap()

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.TRAILING,

false)

.addComponent(

jLabel2,

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

javax.swing.GroupLayout.Alignment.LEADING,

layout.createSequentialGroup()

.addComponent(

jLabel3)

.addPreferredGap(

javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

layout.createSequentialGroup()

.addGap(10,

10,

10)

.addComponent(

jButton1)

.addGap(47,

47,

47)

.addComponent(

jButton2))

.addComponent(

jPasswordField1)

.addComponent(

jTextField1,

javax.swing.GroupLayout.DEFAULT_SIZE,

197,

Short.MAX_VALUE))

.addContainerGap()))));

layout.setVerticalGroup(layout

.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

layout.createSequentialGroup()

.addComponent(jLabel1)

.addPreferredGap(

javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel2)

.addComponent(

jTextField1,

javax.swing.GroupLayout.PREFERRED_SIZE,

24,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(

javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel3)

.addComponent(

jPasswordField1,

javax.swing.GroupLayout.PREFERRED_SIZE,

23,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(

javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(

layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton1)

.addComponent(jButton2))

.addContainerGap(

javax.swing.GroupLayout.DEFAULT_SIZE,

Short.MAX_VALUE)));

pack();

}// /editor-fold

// GEN-END:initComponents

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

About.start();

}

private void jPasswordField1KeyTyped(java.awt.event.KeyEvent evt) {

if (evt.getKeyChar() == '\n') {

String name = jTextField1.getText(); // 获取用户名

String pass = String.valueOf(jPasswordField1.getPassword());// 获取密码

User user = null;

// 未输入用户名

if (name.equals("") || name == null) {

JOptionPane.showMessageDialog(this, "用户名不允许为空!", "cuowu", 0);

return;

}

try {

user = DAOFactory.getIUserDAOInstance().findById(name);

if (user != null) {

if (user.getPass() != null user.getPass().equals(pass)) {

GlobalUser.LOGIN_USER = user; // 记录当前用户

// 进入主界面

Main.start();

this.dispose();

} else {

JOptionPane.showMessageDialog(this, "用户名或密码错误!");

return;

}

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if (user == null) {

JOptionPane.showMessageDialog(this, "用户名或密码错误!", "消息", 0);

return;

}

}

}

private void formKeyTyped(java.awt.event.KeyEvent evt) {

}

private void formKeyPressed(java.awt.event.KeyEvent evt) {

}

private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

jTextField1.setText("");

jPasswordField1.setText("");

jTextField1.requestFocus();

}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

String name = jTextField1.getText(); // 获取用户名

String pass = String.valueOf(jPasswordField1.getPassword());// 获取密码

User user = null;

// 未输入用户名

if (name.equals("")) {

JOptionPane.showMessageDialog(this, "用户名不允许为空!");

return;

}

try {

user = DAOFactory.getIUserDAOInstance().findById(name);

if (user != null) {

if (user.getPass() != null user.getPass().equals(pass)) {

GlobalUser.LOGIN_USER = user; // 记录当前用户

// 进入主界面

Main.start();

this.dispose();

} else {

JOptionPane.showMessageDialog(this, "用户名或密码错误!", "消息", 0);

return;

}

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if (user == null) {

JOptionPane.showMessageDialog(this, "用户名或密码错误!", "消息", 0);

return;

}

}

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {

if (JOptionPane.showConfirmDialog(this, "你确定要退出吗?", "提示",

JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

System.exit(0);

}

}

private void jMenuItem1MouseClicked(java.awt.event.MouseEvent evt) {

System.exit(1);

}

/**

* @param args

* the command line arguments

*/

public static void main(String args[]) {

// System.out.println(Login.class.getResource("src/images/images/login_main.jpg"));

// new javax.swing.ImageIcon(

// Login.class.getResource("../../../../images/login_main.jpg"));

// new Login().setVisible(true);

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new Login().setVisible(true);

}

});

}

// GEN-BEGIN:variables

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JMenu jMenu1;

private javax.swing.JMenu jMenu2;

private javax.swing.JMenuBar jMenuBar1;

private javax.swing.JMenuItem jMenuItem1;

private javax.swing.JMenuItem jMenuItem2;

private javax.swing.JPasswordField jPasswordField1;

private javax.swing.JTextField jTextField1;

// End of variables declaration//GEN-END:variables

}


分享名称:java网上书城系统代码 网上书店java代码
转载来于:http://ybzwz.com/article/ddeiehc.html