资源简介
SSD7所有答案,尽量自己做,不要照抄哦
代码片段和文件信息
package library;
import java.util.*;
import java.sql.*;
import java.text.*;
/**
* class Library represents the functionality of a library
*
* @author iCarnegie
* @version 1.0
*/
public class Library {
// singleton DBWrapper
private DBWrapper myConnection = null;
/**
* class Library constructor
*/
public Library() throws Exception {
myConnection = DBWrapper.Instance();
}
/**
* holdBook places a hold on book with given call number for the given
* member
*
* @param callNumber
* String call number of book to hold
* @param member
* Member member who wishes to hold the book.
* @return boolean
*/
public boolean holdBook(String callNumber Member member) throws Exception {
String sqlQuery = “select count(*) as counted from hold where callnumber=‘“
+ callNumber + “‘ and ssn=‘“ + member.getSSN() + “‘“;
boolean alreadyHeld = false;
ResultSet r = null;
// Select the count of the books. If it is 1 this book is already held.
r = myConnection.runQuery(sqlQuery);
if (r.next()) {
if (r.getInt(“counted“) == 1) {
alreadyHeld = true;
}
}
// if alreadyHeld is true then don‘t place a hold. Place a hold
// otherwise.
if (alreadyHeld) {
return true;
} else {
sqlQuery = “INSERT INTO Hold VALUES (“ + member.getSSN() + “ ‘“
+ callNumber + “‘ CURRENT_TIMESTAMP)“;
if (myConnection.runUpdate(sqlQuery) > 0)
return true;
else
return false;
}
}
/**
* checkinBook checks the book with the specified book id into the library.
*
* @param bookId
* int id of book to check in
* @return boolean
*/
public boolean checkInBook(int bookId) throws Exception {
// Build the sql query.
String sqlQuery = “UPDATE Book SET borrowerssn = null librarianssn = null duedate = null WHERE BookID = “
+ bookId;
// Run the update.
if (myConnection.runUpdate(sqlQuery) > 0)
return true;
else
return false;
}
/**
* approve a check out for book with given book id for a member with given
* member ssn
*
* @param bookId
* int id of book to check out
* @param memberSSN
* int ssn of member who wants to check book out
* @return boolean
*/
private boolean approveCheckout(int bookId int memberSSN) throws Exception {
boolean canCheckOut = true;
// check to see if that book is already checked out
boolean checkedOut = LibraryBook.isCheckedOut(bookId);
if (checkedOut) {
canCheckOut = false;
} else {
// see if another member has higher priority on this book
// We have to check the holds if the number of
// holds on this title exceeds the number of
// available copies.
String callNumber = LibraryBook.getBook(bookId).getCallNumber();
int availabl
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1121 2011-03-20 21:12 SSD7所有练习答案\exam1.sql
文件 2597 2011-03-20 21:12 SSD7所有练习答案\exam3\exam3.txt
文件 2673 2011-03-20 21:12 SSD7所有练习答案\Exercise 1\BookPublisher.html
文件 1540 2011-03-20 21:12 SSD7所有练习答案\Exercise 1\CreateDB.sql
文件 479 2011-03-20 21:12 SSD7所有练习答案\Exercise 1\part3.txt
文件 726 2011-03-20 21:12 SSD7所有练习答案\Exercise 1\Rel-ops.txt
文件 18994 2008-05-29 09:58 SSD7所有练习答案\Exercise10\ssd7-ex10-65\indexes.txt
文件 4167 2011-03-20 21:12 SSD7所有练习答案\Exercise10\ssd7-ex10-65.rar
文件 1691 2011-03-20 21:12 SSD7所有练习答案\Exercise2\answer.sql
文件 2050 2011-03-20 21:12 SSD7所有练习答案\Exercise3\alter_tables.sql
文件 86 2011-03-20 21:12 SSD7所有练习答案\Exercise3\delete_rows.sql
文件 2835 2011-03-20 21:12 SSD7所有练习答案\Exercise3\queries.sql
文件 188363 2011-03-20 21:12 SSD7所有练习答案\Exercise4\Html_Pages.zip
文件 10263 2011-03-20 21:12 SSD7所有练习答案\Exercise4\Library.java
文件 3761 2011-03-20 21:12 SSD7所有练习答案\Exercise4\MemberRegisterController.java
文件 3674 2011-03-20 21:12 SSD7所有练习答案\Exercise4\newmember.jsp
文件 3360 2011-03-20 21:12 SSD7所有练习答案\Exercise4\web.xm
文件 1215 2011-03-20 21:12 SSD7所有练习答案\exercise5\entityattributes.txt
文件 22276 2011-03-20 21:12 SSD7所有练习答案\exercise5\ER.gif
文件 1329 2011-03-20 21:12 SSD7所有练习答案\exercise5\ER.txt
文件 38596 2011-03-20 21:12 SSD7所有练习答案\exercise5\Ex5erd.jpg
文件 2136 2011-03-20 21:12 SSD7所有练习答案\Exercise6\normalization.txt
文件 2584 2011-03-20 21:12 SSD7所有练习答案\Exercise7\relational-model.sql
文件 3263 2011-03-20 21:12 SSD7所有练习答案\Exercise7\relational-schema.txt
文件 6144 2011-03-20 21:12 SSD7所有练习答案\Exercise7\ssd7-ex7.rar
文件 4591 2011-03-20 21:12 SSD7所有练习答案\Exercise9\application.txt
文件 1586 2011-03-20 21:12 SSD7所有练习答案\Exercise9\deadlock(Window 1).txt
文件 1118 2011-03-20 21:12 SSD7所有练习答案\Exercise9\deadlock(Window 2).txt
文件 2772 2011-03-20 21:12 SSD7所有练习答案\Exercise9\deadlock.txt
文件 4591 2011-03-20 21:12 SSD7所有练习答案\Exercise9\Ex9_ssd7\application.txt
............此处省略34个文件信息
评论
共有 条评论