圖書管理課程設計報告
專業 計算機科學與技術
班級 1701
學號 173230117
姓名 張明珠
指導老師 郭丹
目錄
一、 開發背景................................................. 3
二、 需求分析................................................. 3
2.1系統的准備.................................................. 3
2.2知識准備.................................................... 3
2.3功能分析.................................................... 3
2.4開發技術分析................................................ 3
三、 系統設計................................................. 3
3.1系統目標 .................................................. 3
3.2系統功能.................................................... 4
3.3系統用例圖.................................................. 4
3.4核心模塊時序圖.............................................. 5
3.5核心模塊類圖................................................ 5
3.6數據庫設計.................................................. 6
四. 系統測試................................................. 6
4.1頁面無法跳轉................................................ 6
4.2 按鈕無反應.................................................. 7
4.3 功能未實現.................................................. 7
五. 系統實現................................................. 8
六. 心得體會................................................ 15
附件1:..................................................... 16
圖書管理系統
一、開發背景
隨着智能手機的普及,基於Android平台的應用軟件需求也越來越多。寧波東藍數碼有限公司是一家規模較大的軟件公司,隨着公司規模的不斷擴大,目前新增了大量基於Android智能手機方面的業務,但由於業務量較大,公司內部開發人員一時無法滿足要求,現需要外包一些智能手機應用軟件。現假設你所在的公司承接了該公司智能手機外包項目的開發工作。Android平台下的圖書管理系統的開發,能很好的為用戶提供方便,用戶能通過它能隨時隨地的了解系統的實時信息,做到信息的實時化。同時,對於校內的圖書管理系統來說,手機對於學生是必不可少的一個物品,手機客戶端這種形式的圖書管理系統,能更加貼近學生的生活習慣,並且適合學生年齡段的習性,這對學生更多的接觸到圖書館的信息有一定得促進作用。
二、需求分析
2.1系統的准備
操作系統: Android
數據庫系統: SQLite
2.2知識准備
熟悉SQLite的使用: .熟悉Java、Android studio、XML等語言進行數據庫編程。
2.3功能分析
基於Android平台開發的圖書管理系統客戶端從設計者的角度來看,用戶角色主要為學生用戶;功能包括注冊、登錄、書籍查詢、增加一本好書、修改閱讀進度、刪除閱讀記錄等。
2.4開發技術分析
該系統是基於Eclipse軟件並連接Android SDK進行開發的基於Android平台開發的圖書管理系統,數據庫采用較小速度快的SQLite, 是嵌入式移動設備中常用的輕量級數據庫。軟件UI通常使用xml技術設計,由於布局的使用,並且布局之間可以互相嵌套,使得android軟件UI的設計變得非常靈活,力求圖書與學生之間更加親近方便。
三、系統設計
3.1系統目標
(1)系統采用人機交互的方式,界面美觀友好,信息查詢靈活、方便,數據存儲安全可靠;
(2)能夠讓學生更好更方便的了解圖書和閱讀圖書;
(3)豐富學生知識,增加學生閱讀積極性;
(4)能夠對學生信息進行有效的管理;
(5)能夠准確、詳細地了解學生的每月閱讀量;
3.2系統功能
本系統的具體功能如下:
1. 圖書管理:新增、瀏覽圖書。
2.我的書庫: 學生查看閱讀過的圖書、書名、圖書的作者、閱讀量和總量。
3.修改閱讀進度:可以根據閱讀進度修改閱讀量,記錄閱讀的頁數。
4.刪除閱讀記錄:看完的圖書可以及時刪除,不占內存。
5.退出登錄:閱讀完成之后退出登錄。
本系統的系統結構功能圖如圖所示:
系統結構功能圖
3.3系統用例圖
3.4核心模塊時序圖
圖書管理時序圖
3.5核心模塊類圖
圖書管理類圖
3.6數據庫設計
由於本系統是在校學生使用的軟件,需要充分考慮圖書管理和學生閱讀需求等問題,而SQLite是一款輕型的數據庫,它占用資源非常的低,在嵌入式設備中,可能只需要幾百K的內存就夠了。處理速度快,效率高,正好滿足了手機app的需求,所以本系統采用SQLite數據庫。
四.系統測試
4.1頁面無法跳轉
在做完第一個頁面的時候,我非常開心,但是當我要跳轉到第二個頁面的時候,遇到了難題,我卡在了頁面跳轉。
后來,我上百度搜索這個問題怎么解決,原來是因為新增頁面沒有在AndroidManifest.xml中配置,然后就解決了這個問題。
4.2 按鈕無反應
在設計第二個頁面的時候,有三個按鈕,點他沒有反應,我當時都要崩潰了,調試了很久的代碼,還是出不來。
我上網查怎么點按鈕實現連接,到下一個頁面,經過很多次調試,終於解決了,發現提示框是toast方法,而跳轉頁面是intent方法。
4.3 功能未實現
做完第三頁的代碼之后我運行了一下,它沒有實現該有的功能,沒有出來圖書信息,我真的好難啊!遇到好多問題,但最后還是解決了。
經過我不懈的努力,不放棄,終於解決了這些問題!雖然還有很多功能不能實現,也做得特別簡單,但是這是我努力的開始,我會越來越認真的。
四.系統實現
部分關鍵代碼如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sbbj"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/loginxx"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:layout_marginBottom="30dp"
android:layout_marginTop="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="50dp"
android:hint="請輸入賬號"
android:paddingLeft="20dp"
android:textColor="#CC0066"
android:textSize="14sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#11000000" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="50dp"
android:hint="請輸入密碼"
android:paddingLeft="20dp"
android:textColor="#CC0066"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center" >
<Button
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:gravity="center"
android:onClick="clicklogin"
android:text="登 錄"
android:textColor="#ffffffff"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="horizontal" >
<TextView
android:id="@+id/non"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="無法登錄點我找回密碼" />
<TextView
android:id="@+id/news"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="5dp"
android:gravity="left"
android:text="新用戶點我注冊" />
</LinearLayout>
</LinearLayout>
這是登錄、注冊頁面的代碼。(部分代碼)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sbbj"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/isbn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="52dp"
android:orientation="horizontal" >
<TextView
android:layout_width="90dp"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingRight="5dp"
android:text="書號 :" />
<EditText
android:id="@+id/et_isbn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="請輸入這是您讀的第幾本書"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/isbn"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:layout_width="90dp"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingRight="5dp"
android:text="書名" />
<EditText
android:id="@+id/et_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="請輸入書名"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:layout_width="90dp"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingRight="5dp"
android:text="作者" />
<EditText
android:id="@+id/et_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="請輸入作者"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/author"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:layout_width="90dp"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingRight="5dp"
android:text="閱讀量" />
<EditText
android:id="@+id/et_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="請輸入您閱讀了多少"
android:textSize="14dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/price"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:layout_width="90dp"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingRight="5dp"
android:text="總量" />
<EditText
android:id="@+id/et_quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="請輸入書總頁"
android:textSize="14dp" />
</LinearLayout>
<Button
android:id="@+id/btn_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/quantity"
android:layout_marginLeft="10dp"
android:layout_marginTop="24dp"
android:onClick="click1"
android:text="增加一本好書" />
<TextView
android:id="@+id/tv_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/btn_add"
android:textSize="17sp" />
<Button
android:id="@+id/btn_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:onClick="clickout"
android:text=" 退出登錄 "
android:textSize="15sp" />
<Button
android:id="@+id/btn_find"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:onClick="click3"
android:text=" 我的書庫 "
android:textSize="15sp" />
<Button
android:id="@+id/btn_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/btn_find"
android:onClick="click4"
android:text="刪除閱讀記錄" />
<Button
android:id="@+id/btn_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/tv_show"
android:layout_alignRight="@+id/quantity"
android:onClick="click2"
android:text="修改閱讀進度" />
</RelativeLayout>
實現閱讀圖書的增刪改查。(部分代碼)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sbbj"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/image_view_id"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="11"
android:src="@drawable/img_1" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center"
android:text="明珠圖書館"
android:textColor="#FFCCFF"
android:textSize="30sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="horizontal" >
<Button
android:id="@+id/introduce_id"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="圖書介紹"
android:textSize="21sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="horizontal" >
<Button
android:id="@+id/newBook_id"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="add"
android:text="新書閱讀"
android:textSize="21sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4" >
<Button
android:id="@+id/registerStudent_id"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="我的讀書歷史"
android:onClick="list"
android:textSize="21sp" />
</LinearLayout>
</LinearLayout>
第二頁也是圖書管理系統的主頁面,包含三塊:圖書介紹、新書閱讀、我的讀書歷史。(部分代碼)
五.心得體會
我們從這個學期開始學的Android,從一開始的0基礎,不斷的一點點寫基礎代碼,實現基礎功能。甚至一開始的時候在基礎代碼,沒有幾行的情況下都會有許多錯誤,詢問老師和同學,幫助解決bug。到現在的做完一整個課程設計,心里無比的自豪。這個系統主要實現了管理圖書,閱讀圖書,用戶登錄注冊和修改查詢刪除等功能。由於自身經驗不足,盡管按照書本實現代碼,但還是有各種各樣的問題。代碼出現錯誤不知如何修改,陷入無盡的迷茫中,因個人的能力有限,有些功能設計打不開,不夠完善,有待進一步的改善。但是通過這段時間的鍛煉,對於系統設計的理念更為明確,對Eclipse這款軟件的運用真的熟悉掌握了不少。相信在以后的系統設計中,我能夠吸取經驗和教訓,能力不斷提高。多自學一點,不要老是為自己的懶找借口。
總之,通過此次系統設計,真正深刻體會到了有勁無處使得感覺,想做但又很多都不會,還是要在平時多下功夫,每天自學一點,時間長了就都會了,怕的就是堅持不下來,郭丹老師開學就跟我們說了這個“堅持”!真的!很難,但是很有道理!
附件1:
1.課設題目:圖書管理系統
2.技術說明
通過Java代碼調用圖片資源,布局資源文件,字符串資源,顏色資源文件,尺寸資源等,在XML布局文件中調用圖片資源,布局資源文件,字符串資源顏色資源文件,尺寸資源等。通常有5種布局,分別為相對布局,線性布局,幀布局,表格布局,約束布局等。
3.UML類圖
- 代碼
4.1清單文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.book"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.book.LoginActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.book.MainActivity"
android:label="@string/app_name" >
</activity>
<activity android:name="com.example.book.Booklist"
android:label="@string/app_name" >
</activity>
<activity android:name="com.example.book.Hello"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
4.2布局文件:
1.截圖
4.3Java原碼
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class Booklist extends Activity{
Myhelper helper;
private TextView tv_show;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.booklist);
helper = new Myhelper(this);
init();
}
public void init() {
tv_show = (TextView) findViewById(R.id.tv_show);
SQLiteDatabase db = helper.getWritableDatabase();
Cursor cursor = db.query("info", null, null, null, null, null, null);
if (cursor.getCount() == 0) {
tv_show.setText("");
Toast.makeText(this, "沒有數據!", 1).show();
} else {
cursor.moveToFirst();
tv_show.setText("書號:" + cursor.getString(1) + " 書名:"
+ cursor.getString(2) + " 作者:" + cursor.getString(3) + "\n已讀:"
+ cursor.getString(4) + " 總頁:" + cursor.getString(5) + "\n");
}
while (cursor.moveToNext()) {
tv_show.append("\n" + "書號:" + cursor.getString(1) + " 書名:"
+ cursor.getString(2) + " 作者" + cursor.getString(3) + "\n已讀:"
+ cursor.getString(4) + " 總頁:" + cursor.getString(5)+ "\n");
}
cursor.close();
db.close();
}
}