图书预约系统代码java 图书馆预约系统类图( 二 )


{
if(e.getKeyCode()==KeyEvent.VK_ENTER)
{
jb1.doClick();
}
}});
panel1.add(jLabel_name);
panel1.add(jTextField_name);
panel2.add(jLabel_password);
panel2.add(jPasswordField);
panel3.add(jb1);
panel3.add(jb2);
panel4.add(jLabel_title);
panel_all.setLayout(new GridLayout(4,1));
panel_all.add(panel4);
panel_all.add(panel1);
panel_all.add(panel2);
panel_all.add(panel3);
panel_all.setOpaque(false);
jf.setLayout(new BorderLayout());
jf.add(panel_all);
jb1.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent me){
// if(lc.validate(jTextField_name.getText().trim(),new String(jPasswordField.getPassword()).trim())){
//doLogin();
//new MainFrame();
//}
//else
//JOptionPane.showMessageDialog(null, "Password doesn't match account,please try again!");
}
});
jb2.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent me){
System.exit(0);
}
});
jf.setVisible(true);
jf.repaint();
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/* public void doLogin(){
cid=jTextField_name.getText().trim();
passwd=jPasswordField.getText().trim();
String sql = "select *from customer where "+"cid='"+cid+"' and password='"+passwd+"'";
if (DB.connectDB()) {
if (DB.query(sql)){
System.out.print("登陆成功");
jf.dispose();
new MainFrame(cid);
return;
} else {
System.out.print("登陆失败");
return;
}
}
}
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new Login();
}
}
用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; i2; i++) {
//self[i].showBookInfo();
//}
for (int i = 0; i3; 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;

推荐阅读