資訊管理系專題口試委員審定書 行動化點餐預定系統 -以早餐店為例 指導教授 林 甘 敏 教授 組員名單 黃 共 進 988C055 許 子 文 988C025 賴 銀 洲 988C043 徐 浩 荏 988C077 指導教授 口試委員 中華民國 102 年 I 5月
誌謝 本專題報告得以順利完成, 首先要感謝恩師林甘敏老師細心引導我們, 耐心的協助我們, 克服研究過程中所面臨的困難, 給予我們最大的協助, 使本專題得以順利完成 研究報告口試期間, 感謝賴東彥老師 羅國彥老師不辭辛勞細心審閱, 不僅給予我們指導, 並且提供寶貴的建議, 使我們的專題內容以更臻完善, 在此由衷的感謝 最後, 感謝系上諸位老師在各學科領域的熱心指導, 增進商業管理知識範疇, 在此一併致上最高謝意 黃共進許子文賴銀洲徐浩荏 謹誌 中華民國 102 年 5 月於嶺東 II
摘 要 隨著行動科技的進步, 手機已相當普及幾乎人手一機, 而民以食為天, 每天 食用早餐是為身體保持健康狀態必作的事, 目前台灣早餐店林立, 多數的早餐店 依舊維持以電話訂購餐點的方式, 目前尚無餐廳提供客人使用手機方式訂餐 檢視目前正在開發的手機市場, 智慧型手機廠牌多種百般便利, 其中以 Android 系統最為普遍, 如何透過智慧手機進行點餐, 並研發一套系統, 是本研究 的目的, 本研究成果包括以下幾點 : 1. 減少早餐店接聽電話時所用掉的時間成本 2. 加速早餐店運作速度及備料的準確度 3. 增加早餐店業績 4. 節省消費者等候的時間, 增加取餐便利性 5. 增加使用者智慧型手機實用度 III
目 錄 摘目圖目錄表目錄 要 III 錄 IV VI VII 第壹章緒論 1 1.1 研究背景與動機 1 1.2 研究目的 1 第貳章文獻探討 2 2.1 手機得來速 Drive-Through Cell Phone 2 2.2 手機系統 3 2.3 使用工具 4 2.3.1 Java 4 2.3.2 XML 4 2.3.3 點對點技術 4 第參章研究方法 6 3.1 研究流程 6 3.2 軟硬體設備 7 3.3 功能架構圖 9 3.4 點餐流程 11 第肆章系統實作 12 第伍章結論 18 IV
參考文獻 19 附錄 20 程式碼 20 工作分配表 50 V
圖目錄 2-1 程式架構 4 3-1 研究流程圖 8 3-2 使用端架構圖 11 3-3 店家端架構圖 12 3-4 點餐流程圖 13 4-1 使用者主選單 14 4-2 點餐畫面 15 4-3 選取餐點畫面 16 4-4 點餐清單 17 4-5 查詢點餐畫面 18 4-6 店家端清單明細 19 VI
表目錄 3-1 手機規格 10 VII
第壹章緒論 1.1 研究背景與動機 早餐店點餐系統到了高科技時代, 卻依舊以傳統的電話點餐及紙本點餐, 維持資源高耗損的狀態, 在 Android App 專屬發布平台 Google Play 分別搜尋 早餐 及 點餐 雙關鍵字後發現,2012 年 10 月前並沒有早餐店專屬的相關程式 隨著時代的進步, 智慧型手機蓬勃發展, 在近年來電信業者的強力優惠下, 多數人已經更換智慧型手機代替傳統型手機, 就連主打通訊方便的亞太型手機也已經出現多款智慧型手機, 目前市場智慧型手機可說是人手一支, 甚至是一人多支的狀況, 根據 IDC( 國際數據資訊 ) 台灣手機產業調查季報顯示,2012 年第三季台灣的智慧型手機市佔率已達七成以上, 尤其以 Android 平台市場占有率最高, 因此發展手機應用已經成為時代趨勢 [4] 1.2 研究目的 基於上述的動機, 本研究主要的目的在探討如何透過智慧手機進行點餐, 並研發一套使用在智慧型手機上的系統, 本研究的成果包括以下幾點 : 1. 減少早餐店接聽電話時所用掉的時間成本 2. 加速早餐店運作速度及備料的準確度 3. 增加早餐店業績 4. 節省消費者等候的時間, 增加取餐便利性 5. 增加使用者智慧型手機實用度 1
第貳章文獻探討 2.1 手機得來速 Drive-Through Cell Phone 利用新的 行動傳輸裝置 來取代傳統以人到場的排隊模式, 善用行動 裝置的眾多優點, 以 JAVA 製作, 傳送資訊至後台可馬上執行外送服務, 減 少點餐人力資源 [3] 優點 : 1. 訂購方便 2. 可查詢附近商家 3. 告知外送所需額度之差額 缺點 : 1. 不能廣泛通用於所有商家 2. 無法適用於餐廳內 3. 可能會產生無法即時更新各餐廳最新資訊 4. 顧客無法設定最高限額來避免超支 5. 無法確認是否有假訂單出現 6. 此程式與本專題之相關性 : 此程式與本專題之相關性 : 此程式為 PDA 專屬之程式, 本專題取之 行動化 與 點餐 兩項特 點於搭載 Android 系統之行動裝進行軟體的設計 2
2.2 手機系統 Android 是一個以 Linux 為基礎的半開放原始碼作業系統, 主要用於行動設備, 由 Google 成立的 Open Handset Alliance(OHA, 開放手機聯盟 ) 持續領導與開發中 Android 系統最初由安迪 魯賓 (Andy Rubin) 開發製作, 最初主要支援手機, 於 2005 年 8 月被美國科技企業 Google 收購 2007 年 11 月,Google 與 84 家硬體製造商 軟體開發商及電信營運商成立開放手持設備聯盟來共同研發改良 Android 系統, 隨後,Google 以 Apache 免費開源許可證的授權方式, 發布了 Android 的源代碼 讓生產商推出搭載 Android 的智慧型手機, Android 作業系統後來更逐漸拓展到平板電腦及其他領域上 圖 2-1 程式架構圖 3
2.3 使用工具 2.3.1 Java Java 是一種簡單的, 面向對象的, 分散式的, 解釋型的, 健壯安全的, 結構中立的, 可移植的, 性能優異 多執行緒的動態語言 由 Sun Microsystems 公司于 1995 年 5 月推出的 Java 程式設計語言和 Java 平臺的總稱 用 Java 實現的 HotJava 流覽器 ( 支援 Java applet) 顯示了 Java 的魅力 : 跨平臺 動態的 Web Internet 計算 從此,Java 被廣泛接受并推動了 Web 的迅速發展, 常用的流覽器現在均支援 Java applet 另一方面,Java 技術也不斷更新 2.3.2 XML 可延伸標記式語 (extensible Markup Language, 簡稱 :XML), 是一種標記式語言 標記指電腦所能理解的訊息符號, 透過此種標記, 電腦之間可以處理包含各種訊息的文章等 如何定義這些標記, 既可以選擇國際通用的標記式語言, 比如 HTML, 也可以使用像 XML 這樣由相關人士自由決定的標記式語言, 這就是語言的可延伸性 XML 是從標準通用標記式語言 (SGML) 中簡化修改出來的 它主要用到的有可延伸標記式語言 可延伸樣式語言 (XSL) XBRL 和 XPath 等 2.3.3 點對點技術 點對點技術 (peer-to-peer, 簡稱 P2P) 又稱對等網際網路技術, 是一種網路新技術, 依賴網路中參與者的計算能力和頻寬, 而不是把依賴都聚集在較少的幾台伺服器上 請注意與 point-to-point 之間的區別,peer-to-peer 一般譯為端對端或者群對群, 指對等網中的節點 ;point-to-point 一般譯為點對點, 對應於普通網路節點 P2P 網路通常用於透過 Ad Hoc 連線來連線節 4
點 這類網路可以用於多種用途, 各種檔案分享軟體已經得到了廣泛的使用 P2P 技術也被使用在類似 VoIP 等即時媒體業務的資料通訊中 純點對點網路沒有客戶端或伺服器的概念, 只有平等的同級節點, 同時對網路上的其它節點充當客戶端和伺服器 這種網路設計模型不同於客戶端 - 伺服器模型, 在客戶端 - 伺服器模型中通訊通常來往於一個中央伺服器 有些網路 ( 如 Napster OpenNAP, 或 IRC @find) 的一些功能 ( 比如搜尋 ) 使用客戶端 - 伺服器結構, 而使用 P2P 結構來實作另外一些功能 類似 Gnutella 或 Freenet 的網路則使用純 P2P 結構來實作全部的任務 一般報章都稱 P2P 是點對點技術, 但其實是錯的, 實為解作群對群 (Peer-to-Peer) 在虛擬私人網路 VPN (Virtual Private Network) 中, 也有 P2P 這個名稱, 它才是真正解作點對點 (Point-to-Point) 5
第參章研究方法 3.1 研究流程 一開始確認研究動機並開始規劃, 進而了解市場狀況, 經過實地確立製 作方法, 最後通過測試與重新設計修改的方式完成最後成品 研究動機 實際使用了解 android market 上之軟體 確定題目 學習 android 程式 程式規劃與設計 前台 後台 程式可 行性 否 是 系統完成 & 撰寫報告 圖 3-1 研究流程圖 6
3.2 軟硬體設備 本專題使用軟體 eclipse 搭配擴充元件 SDK 與 JDK 來開發 Android 程式, 並搭配智慧型手機進行實作測試 Eclipse Eclipse 是著名的跨平台的自由整合式開發環境 (IDE) 最初主要用來 Java 語言開發, 目前亦有人透過外掛程式使其作為其他語言的開發工具 Eclipse 的外掛程式機制是輕型軟體元件化架構 使用外掛程式來提供所有的附加功能, 例如支援 Java 以外的其他語言 已有的分離外掛程式已經能夠支援 C/C++(CDT) PHP Perl Ruby,Python telnet 和資料庫開發 外掛程式架構能夠支援將任意的擴充功能加入到現有環境中, 例如配置管理, 而決不僅僅限於支援各種程式語言 7
手機平台與規格 本專題將由兩支手機分別進行測試, 確保在不同廠牌的智慧型手機有辦 法正確執行, 以下為其規格表 表 3-1 手機規格 [1][2] 規 格 HTC Desire 作業系統 ( 平台 ) Android 2.1 處理器 Qualcomm 8250, 1GHz RAM 記憶體 512MB 藍牙版本 V2.1 音樂播放 AAC,MP3,WAV,WMA,M4A 傳輸介面 USB, wifi, 藍牙記憶卡插槽 microsd Sony Arc S 作業系統 ( 平台 ) Android 2.3 Gingerbread 處理器 1.4 GHz RAM 記憶體 256MB 藍牙版本 V2.1 音樂播放 MP3,eAAC+,WMA,WAV 傳輸介面 : USB, wifi, 藍牙記憶卡插槽 MicroSD 8
3.3 功能架構圖 使用者在下載程式後會看到點餐 點餐查詢兩大項功能 ( 如圖 3-2 所示 ) 使用者 點餐 點餐查詢 點餐畫面 點餐明細 訂購完成 取餐 圖 3-2 使用端架構圖 9
店家端畫面可查詢訂單明細 ( 如圖 3-3 所示 ), 包含訂購餐點品項 數 量以及總金額和代碼資訊 店家 訂單查詢 訂單明細 圖 3-3 店家端架構圖 10
3.4 點餐流程 進入點餐畫面後可執行點餐動作 ( 如圖 3-4 所示 ) 一般點餐畫面 選購餐點 是否確定 選購餐點 否 是 完成 返回點餐畫面 圖 3-4 點餐流程圖 11
第肆章系統實作 安裝完程式後, 進入系統最先看到的主選單, 有一般點餐及訂單查詢兩 個按鍵 ( 如圖 4-1 所示 ) 圖 4-1 使用者主選單進入點餐選取的畫面, 可選取所需食物與飲料並加入訂購清單之中, 選購的食物可在顯示區中看見, 並選取所需數量, 如有特殊處理要求可填於特殊需求欄 ( 如圖 4-2 所示 ) 12
圖 4-2 點餐畫面 點選食物清單按鈕, 跳出食物清單並選擇 ( 如圖 4-3 所示 ), 確認後點 13
選加入點購清單 圖 4-3 選取餐點並加入 14
點餐完成後可看到方才所選取之餐點以及顯示總金額 ( 如圖 4-4 所示 ) 圖 4-4 點餐清單 15
完成點餐後可於訂單查詢功能內, 查詢到已送出的訂單, 以及取 餐時間, 也可刪除清單之紀錄 ( 如圖 4-5 所示 ) 圖 4-5 查詢點餐畫面 店家端可收到點購清單之畫面 ( 如圖 4-6 所示 ) 16
圖 4.6 店家端清單明細 17
第伍章結論 本系統規劃以通用式系統作為設計原則, 讓每間早餐店都可以使用, 除了增加可使用的對象外, 可提高系統的利用價值, 降低系統維護的成本與開發的成本 預計使用無線傳輸方式, 可使所有持有 Android 智慧型手機的客戶可藉由網路在家點餐 顧客在使用本程式後, 可大量減少在早餐店等餐的時間, 店家僅需在顧客到場取餐時或現場點餐時回到櫃台, 不須安排多人接聽電話點餐, 不僅可減少人力需求與點餐紙張的浪費, 更可以減少時間資源的浪費, 並提高餐點製作的效率 此外, 使用本程式後因顧客不需到櫃檯點餐或到櫃台索取服務, 因此會增加顧客的滿意度 總體而論, 本研究的成果包括以下幾點 : 1. 減少時間資源浪費及所需人力成本 2. 增加智慧型手機實用度 3. 提高早餐店運作效率 4. 增加點餐便利性及減少點餐時間 5. 改善早餐店候餐擁擠現象 6. 提高顧客滿意度 7. 利用點餐系統免費下載達到行銷功能 本專題未來發展希望以現有設計的程式為主體, 加入會員制功能, 配合點數及折扣方案讓使用者享有優惠, 並防止惡意點餐的情形發生 美化程式畫面, 加入餐點圖案以及卡路里熱量標示, 使用者可依照此資訊來參考攝取熱量, 並且希望將程式模組化, 廣泛使用於各式不同店家, 達成客製化服務 18
參考文獻 [1] 手機規格 HTC 官方網站 取自 : http://www.htc.com/tw/ [2] 手機規格 SONY 官方網站 取自 : http://store.sony.com.tw [3] 周俊羽 楊尚勳 陳冠瑋 傅毅欣 (2009) 手機得來速- 崑山科技大學專題 下載日期 :2011/5/19 取自: http://ir.lib.ksu.edu.tw/handle/987654321/839 [4] 鄭緯筌 (2012) IDC: 台灣智慧型手機市佔率達七成以上 數位時代網站 取自: http://www.bnext.com.tw/article/view/cid/115/id/25606 [5]Google Play 網站 https://play.google.com/store [6]Google! Android 2 手機應用程式設計入門第三版蓋索林, 松崗資產管理股份有限公司,2009.12 19
附 錄 此段程式碼為店家端顯示畫面, 內容呈現客戶端所發送過來之點餐清單內容, 包含餐點 總金額 取餐時間 程式碼 APP:Link( 店家端 ) MainActivity.java package link.link; import java.io.bufferedreader; import java.io.inputstreamreader; import java.net.serversocket; import java.net.socket; import android.os.bundle; import android.os.handler; import android.os.message; import android.r.integer; import android.annotation.suppresslint; import android.app.activity; import android.view.menu; import android.view.view; import android.widget.textview; @SuppressLint("HandlerLeak") public class MainActivity extends Activity String all=""; String temp=""; Handler hr; @Override protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); new Thread() 20
public void run() try try ServerSocket sesocket = new ServerSocket(8888); while(true) Socket sock = sesocket.accept(); InputStreamReader inputstreamreader = new InputStreamReader(sock.getInputStream()); BufferedReader bufferedreader = new BufferedReader(inputStreamReader); temp=bufferedreader.readline(); Message m = new Message(); MainActivity.this.hr.sendMessage(m); sock.close(); catch (Exception e) // TODO: handle exception System.out.println("Fail"); e.printstacktrace(); catch (Exception threadexception) threadexception.printstacktrace();.start(); hr = new Handler() public void handlemessage(message msg) TextView e = (TextView) findviewbyid(r.id.e); String temptemp[] = temp.split("."); String tempsplitstring=""; for(int i=0;i<temptemp.length;i++) tempsplitstring=temptemp[i]+"\n"; 21
all=all+tempsplitstring; e.settext(all); ; @Override public boolean oncreateoptionsmenu(menu menu) // Inflate the menu; this adds items to the action bar if it is present. getmenuinflater().inflate(r.menu.main, menu); return true; 22
此段程式碼內容為使用者端之點餐畫面, 包含 textview edittext button 等元件用以設計出選取餐點功能, 並顯示於畫面上 APP:TEST( 使用者端 ) 1.Low_order.java package te.test; import java.util.arrays; import android.app.activity; import android.app.alertdialog; import android.app.dialog; import android.app.alertdialog.builder; import android.content.dialoginterface; import android.content.intent; import android.os.bundle; import android.view.contextmenu; import android.view.menuitem; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.radiobutton; public class Low_order extends Activity String price,price2; int total_price=0,total2_price=0; int count=0; int time_record; final int times = 4; final int foodn = 5; final int drinkn = 5; final int packn = 5; final int food=3; final int f_1=1; final int f_2=2; final int f_3=3; 23
final int f_4=4; final int f_5=5; final int d_1=6; final int d_2=7; final int d_3=8; final int d_4=9; final int d_5=10; int n=0,m=0,a=0,mm; int i=0,j=0,l=0,o=0,q=0,s=0,z=20; String[] foodok = new String[z]; //i String[] drinkok = new String[z]; //j String[] foodnum = new String[z]; //l String[] drinknum = new String[z]; //o String[] foodsp = new String[z]; //q int[] temp_money=new int[z]; int[] temp2_money=new int[z]; int[] drinksp = new int[z]; //s int[] fm = new int[z]; int[] dm = new int[z]; @Override public void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.low_order); Button backstep = (Button)findViewById(R.id.backstep); backstep.setonclicklistener(new Button.OnClickListener() public void onclick(view v) Intent intent = new Intent(); intent.setclass(low_order.this,choose.class); startactivity(intent); Low_order.this.finish(); ); Button timebtn = (Button)findViewById(R.id.time); 24
// 取餐時間 timebtn.setonclicklistener(new View.OnClickListener() public void onclick(view v) n=0; showdialog(n); ); Button foodnumber = (Button)findViewById(R.id.foodnumber); // 食物數量 foodnumber.setonclicklistener(new View.OnClickListener() ); public void onclick(view v) n=1; showdialog(n); Button foodmenu = (Button)findViewById(R.id.foodmenu); foodmenu.setonclicklistener(new View.OnClickListener() public void onclick(view v) n=4; showdialog(n); ); Button drinknumber = (Button)findViewById(R.id.drinknumber); // 飲料數量 drinknumber.setonclicklistener(new View.OnClickListener() public void onclick(view v) 25
n=2; showdialog(n); ); Button foodcencel = (Button)findViewById(R.id.foodcencel); // 食物清空 foodcencel.setonclicklistener(new View.OnClickListener() public void onclick(view v) EditText fd = (EditText)findViewById(R.id.fooddetail); EditText fh = (EditText)findViewById(R.id.foodhow); EditText fs = (EditText)findViewById(R.id.foodspecial); fd.settext(""); fh.settext(""); fs.settext(""); ); Button drinkcencel = (Button)findViewById(R.id.drinkcencel); // 飲品清空 drinkcencel.setonclicklistener(new View.OnClickListener() public void onclick(view v) EditText dd = (EditText)findViewById(R.id.drinkdetail); EditText dh = (EditText)findViewById(R.id.drinkhow); dd.settext(""); dh.settext(""); ); this.registerforcontextmenu(findviewbyid(r.id.foodmenu)); this.registerforcontextmenu(findviewbyid(r.id.drinkmenu)); Button foodplus = (Button)findViewById(R.id.foodplus); foodplus.setonclicklistener(new View.OnClickListener() 26
public void onclick(view v) EditText fd = (EditText)findViewById(R.id.fooddetail); EditText fh = (EditText)findViewById(R.id.foodhow); EditText fs = (EditText)findViewById(R.id.foodspecial); if("".equals(fd.gettext().tostring().trim())) n=999; showdialog(n); else if("".equals(fh.gettext().tostring().trim())) n=998; showdialog(n); else total_price=count*integer.parseint(price); foodok[i]=fd.gettext().tostring(); foodnum[j]=fh.gettext().tostring(); foodsp[q]=fs.gettext().tostring(); temp_money[i]=total_price; fd.settext(""); fh.settext(""); fs.settext(""); i++;j++;q++; ); Button drinkplus = (Button)findViewById(R.id.drinkplus); drinkplus.setonclicklistener(new View.OnClickListener() public void onclick(view v) 27
EditText dd = (EditText)findViewById(R.id.drinkdetail); EditText dh = (EditText)findViewById(R.id.drinkhow); if("".equals(dd.gettext().tostring().trim())) n=999; showdialog(n); else if("".equals(dh.gettext().tostring().trim())) n=998; showdialog(n); else total2_price=count*integer.parseint(price2); drinkok[l]=dd.gettext().tostring(); drinknum[o]=dh.gettext().tostring(); RadioButton cold = (RadioButton)findViewById(R.id.cold); RadioButton normal = (RadioButton)findViewById(R.id.normal); RadioButton hot = (RadioButton)findViewById(R.id.hot); temp2_money[l]=total2_price; dd.settext(""); dh.settext(""); if(cold.ischecked()) drinksp[s]=1; else if(normal.ischecked()) drinksp[s]=2; else if(hot.ischecked()) 28
drinksp[s]=3; l++;o++;s++; ); Button detail = (Button)findViewById(R.id.detail); detail.setonclicklistener(new View.OnClickListener() public void onclick(view v) Intent intent=new Intent(Low_order.this,List_1.class); Bundle bundle = new Bundle(); bundle.putstringarray("foodok", foodok); bundle.putstringarray("drinkok", drinkok); bundle.putstringarray("foodnum", foodnum); bundle.putstringarray("drinknum",drinknum); bundle.putstringarray("foodsp", foodsp); bundle.putintarray("drinksp", drinksp); bundle.putintarray("temp_money",temp_money); bundle.putint("time_record",time_record); bundle.putintarray("temp2_money", temp2_money); intent.putextras(bundle); startactivity(intent); ); Button re = (Button)findViewById(R.id.re); re.setonclicklistener(new View.OnClickListener() public void onclick(view v) Intent intent = new Intent(); intent.setclass(low_order.this,choose.class); 29
); startactivity(intent); @Override public void oncreatecontextmenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuinfo) if(v==findviewbyid(r.id.foodmenu)) menu.add(0,f_1,0,r.string.f1); menu.add(0,f_2,0,r.string.f2); menu.add(0,f_3,0,r.string.f3); menu.add(0,f_4,0,r.string.f4); else if(v==findviewbyid(r.id.drinkmenu)) menu.add(0,d_1,0,r.string.d1); menu.add(0,d_2,0,r.string.d2); menu.add(0,d_3,0,r.string.d3); menu.add(0,d_4,0,r.string.d4); menu.add(0,d_5,0,r.string.d5); @Override public boolean oncontextitemselected(menuitem mi) EditText dd = (EditText)findViewById(R.id.drinkdetail); switch(mi.getitemid()) case f_1: n=4; 30
showdialog(n); break; case f_2: n=5; showdialog(n); break; case f_3: n=6; showdialog(n); break; case f_4: n=7; showdialog(n); break; case f_5: n=8; showdialog(n); break; case d_1: dd.settext(mi.gettitle()+" "+getresources().getstringarray(r.array.drprice)[0]+" 元 "); price2=getresources().getstringarray(r.array.drprice)[0]; break; case d_2: dd.settext(mi.gettitle()+" "+getresources().getstringarray(r.array.drprice)[1]+" 元 "); price2=getresources().getstringarray(r.array.drprice)[1]; break; case d_3: dd.settext(mi.gettitle()+" "+getresources().getstringarray(r.array.drprice)[2]+" 元 "); price2=getresources().getstringarray(r.array.drprice)[2]; break; case d_4: dd.settext(mi.gettitle()+" "+getresources().getstringarray(r.array.drprice)[3]+" 元 "); price2=getresources().getstringarray(r.array.drprice)[3]; 31
break; case d_5: dd.settext(mi.gettitle()+" "+getresources().getstringarray(r.array.drprice)[4]+" 元 "); price2=getresources().getstringarray(r.array.drprice)[4]; break; return true; @Override protected Dialog oncreatedialog(int id) Dialog dialog = null; switch(id) case 0: Builder b = new AlertDialog.Builder(this); b.settitle(r.string.time); b.setsinglechoiceitems(r.array.time, 0, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) EditText et = (EditText)findViewById(R.id.timehow); et.settext(getresources().getstringarray(r.array.time)[which]); time_record=integer.parseint((getresources().getstringarray(r.array.timepl us)[which])); ); b.setpositivebutton(r.string.complete, 32
new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) ); dialog = b.create(); break; case 1: Builder c = new AlertDialog.Builder(this); c.settitle(r.string.food); c.setsinglechoiceitems(r.array.num, 0, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) EditText et = (EditText)findViewById(R.id.foodhow); et.settext(getresources().getstringarray(r.array.num)[which]); ); count=integer.parseint(getresources().getstringarray(r.array.num)[which] ); c.setpositivebutton(r.string.complete, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) ); dialog = c.create(); break; case 2: Builder d = new AlertDialog.Builder(this); d.settitle(r.string.drink); d.setsinglechoiceitems(r.array.num, 0, 33
new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) EditText et = (EditText)findViewById(R.id.drinkhow); et.settext(getresources().getstringarray(r.array.num)[which]); ); count=integer.parseint(getresources().getstringarray(r.array.num)[which] ); d.setpositivebutton(r.string.complete, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) ); dialog = d.create(); break; case 4: Builder f1 = new AlertDialog.Builder(this); //f.settitle(r.string.pack); f1.setsinglechoiceitems(r.array.fo, 0, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) EditText et = (EditText)findViewById(R.id.fooddetail); et.settext(getresources().getstringarray(r.array.fo)[which]+" "+ getresources().getstringarray(r.array.foprice)[which]+" 元 "); 34
price=getresources().getstringarray(r.array.foprice)[which]; ); f1.setpositivebutton(r.string.complete, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) ); dialog = f1.create(); break; case 5: Builder f2 = new AlertDialog.Builder(this); //f.settitle(r.string.pack); f2.setsinglechoiceitems(r.array.fo2, 0, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) EditText et = (EditText)findViewById(R.id.fooddetail); et.settext(getresources().getstringarray(r.array.fo2)[which]+" "+ getresources().getstringarray(r.array.fo2price)[which]+" 元 "); price=getresources().getstringarray(r.array.fo2price)[which]; ); f2.setpositivebutton(r.string.complete, new DialogInterface.OnClickListener() 35
public void onclick(dialoginterface dialog, int which) ); dialog = f2.create(); break; case 6: Builder f3 = new AlertDialog.Builder(this); //f.settitle(r.string.pack); f3.setsinglechoiceitems(r.array.fo3, 0, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) EditText et = (EditText)findViewById(R.id.fooddetail); et.settext(getresources().getstringarray(r.array.fo3)[which]+" "+ getresources().getstringarray(r.array.fo3price)[which]+" 元 "); price=getresources().getstringarray(r.array.fo3price)[which]; ); f3.setpositivebutton(r.string.complete, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) ); dialog = f3.create(); break; case 7: Builder f4 = new AlertDialog.Builder(this); //f.settitle(r.string.pack); f4.setsinglechoiceitems(r.array.fo4, 0, new DialogInterface.OnClickListener() 36
public void onclick(dialoginterface dialog, int which) EditText et = (EditText)findViewById(R.id.fooddetail); et.settext(getresources().getstringarray(r.array.fo4)[which]+" "+ getresources().getstringarray(r.array.fo4price)[which]+" 元 "); price=getresources().getstringarray(r.array.fo4price)[which]; ); f4.setpositivebutton(r.string.complete, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) ); dialog = f4.create(); break; case 998: Builder de2 = new AlertDialog.Builder(this); de2.settitle(r.string.bug); de2.setmessage(r.string.bugnum); de2.setpositivebutton(r.string.complete, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) ); dialog = de2.create(); break; case 999: Builder de = new AlertDialog.Builder(this); 37
de.settitle(r.string.bug); de.setmessage(r.string.bug_o); de.setpositivebutton(r.string.complete, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) ); dialog = de.create(); break; default: break; return dialog; 38
此段程式碼為送出清單後, 使用者可於自身手機查詢已點過之點餐清 單, 若紀錄太繁多, 使用者可自行執行刪除之動作 2. Check.java package te.test; import java.io.bufferedreader; import java.io.fileinputstream; import java.io.inputstreamreader; import android.os.bundle; import android.preference.preference; import android.app.activity; import android.content.intent; import android.content.sharedpreferences; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.textview; public class Check extends Activity private static final String file_name="file"; @Override public void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.check); TextView list_d = (TextView)findViewById(R.id.list_d); Button ok = (Button)findViewById(R.id.ok); Button del = (Button)findViewById(R.id.del); try FileInputStream stream = openfileinput(file_name); BufferedReader in = new BufferedReader(new InputStreamReader(stream)); 39
String all=""; while((all = in.readline())!=null) list_d.append(all); list_d.append("\n"); list_d.append("\n"); in.close(); catch(exception e) ok.setonclicklistener(new Button.OnClickListener() ); public void onclick(view v) Intent intent = new Intent(); intent.setclass(check.this,choose.class); startactivity(intent); del.setonclicklistener(new Button.OnClickListener() public void onclick(view arg0) try deletefile(file_name); finish(); ); catch(exception e) 40
@Override public boolean oncreateoptionsmenu(menu menu) getmenuinflater().inflate(r.menu.activity_main, menu); return true; 41
此段程式碼為使用者主選單畫面, 包含點餐及清單查詢兩按鈕, 點選 後可連結至個別畫面 3. Choose.java package te.test; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.widget.button; public class Choose extends Activity @Override protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.choose); Button lowpaid = (Button)findViewById(R.id.lowpaid); lowpaid.setonclicklistener(new Button.OnClickListener() public void onclick(view v) Intent intent = new Intent(); intent.setclass(choose.this,low_order.class); startactivity(intent); ); Button look = (Button)findViewById(R.id.look); look.setonclicklistener(new Button.OnClickListener() public void onclick(view v) Intent intent = new Intent(); intent.setclass(choose.this,check.class); 42
startactivity(intent); ); 43
此段程式碼內容為確定點餐後之畫面, 包含所點之餐點清單 總金額 以及取餐時間等資訊 4. List_1.java package te.test; import java.io.bufferedreader; import java.io.bufferedwriter; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstreamreader; import java.io.outputstreamwriter; import java.io.printwriter; import java.net.inetaddress; import java.net.serversocket; import java.net.socket; import java.net.unknownhostexception; import android.os.bundle; import android.app.activity; import android.content.intent; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.toast; import android.text.inputtype; import android.text.format.*; public class List_1 extends Activity int i, fsum = 0, dsum = 0, sum = 0, o, p; String ds, food, drink, code, money, all; Time current_time = new Time(); public InetAddress ServerIP; public int port = 0; public Socket socket; public PrintWriter output = null; 44
private static final String file_name = "file"; @Override public void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.list_1); Intent intent = getintent(); Bundle bundle = intent.getextras(); final EditText food_show = (EditText) findviewbyid(r.id.food_show); final EditText drink_show = (EditText) findviewbyid(r.id.drink_show); final EditText money_show = (EditText) findviewbyid(r.id.money_show); final EditText code_show = (EditText) findviewbyid(r.id.code_show); String[] foodok = (String[]) (bundle!= null? bundle.getstringarray("foodok") : ""); String[] foodnum = (String[]) (bundle!= null? bundle.getstringarray("foodnum") : ""); String[] foodsp = (String[]) (bundle!= null? bundle.getstringarray("foodsp") : ""); String[] drinkok = (String[]) (bundle!= null? bundle.getstringarray("drinkok") : ""); String[] drinknum = (String[]) (bundle!= null? bundle.getstringarray("drinknum") : ""); final int time_record = (Integer) (bundle!= null? bundle.getint("time_record") : ""); int[] drinksp = (int[]) (bundle!= null? bundle.getintarray("drinksp") : ""); int[] temp_money = (int[]) (bundle!= null? bundle.getintarray("temp_money") : ""); int[] temp2_money = (int[]) (bundle!= null? bundle.getintarray("temp2_money") : ""); 45
/* * food_show.setinputtype(inputtype.type_null); * drink_show.setinputtype(inputtype.type_null); * money_show.setinputtype(inputtype.type_null); * code_show.setinputtype(inputtype.type_null); */ for (i = 0; i < foodok.length; i++) if (foodok[i]!= null) food_show.append(foodok[i] + "\t\t X" + foodnum[i]); food_show.append(foodsp[i]); else break; for (i = 0; i < drinkok.length; i++) if (drinkok[i]!= null) if (drinksp[i] == 1) ds = " 冰 "; else if (drinksp[i] == 2) ds = " 溫 "; else if (drinksp[i] == 3) ds = " 熱 "; drink_show.append(drinkok[i] + "(" + ds + ")\t\t X" + drinknum[i]); else break; for (i = 0; i < temp_money.length; i++) fsum += temp_money[i]; for (i = 0; i < temp2_money.length; i++) dsum += temp2_money[i]; 46
sum = fsum + dsum; money_show.append("" + sum); current_time.settonow(); int current_hour = current_time.hour; int current_min = current_time.minute; switch (time_record) case 10: current_min += 10; break; case 30: current_min += 30; break; case 1: current_hour += 1; break; case 2: current_hour += 2; break; default: break; if (current_min > 60) current_min -= 60; current_hour += 1; else if (current_hour >= 24) current_hour -= 24; code_show.append(current_hour + ":" + current_min); Button en = (Button) findviewbyid(r.id.en); en.setonclicklistener(new Button.OnClickListener() public void onclick(view v) food = food_show.gettext().tostring(); drink = drink_show.gettext().tostring(); 47
code = code_show.gettext().tostring(); money = money_show.gettext().tostring(); all = food+"."+ drink+"."+ money+"."+code; try FileOutputStream stream = openfileoutput(file_name,mode_append); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(stream)); out.write(all); out.newline(); out.close(); catch(exception e) new Thread() public void run() try socket = new Socket("192.168.2.100", 8888); try output = new PrintWriter(socket.getOutputStream(), true); output.println(all); catch (IOException e) // TODO Auto-generated catch block Toast.makeText(List_1.this, "Senderror", Toast.LENGTH_SHORT).show(); catch (UnknownHostException e) // TODO Auto-generated catch block e.printstacktrace(); catch (IOException e) // TODO Auto-generated catch block e.printstacktrace(); 48
.start(); Toast.makeText(List_1.this, all, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.setclass(list_1.this, Choose.class); startactivity(intent); List_1.this.finish(); ); 49
工作分配表 黃共進 賴銀洲 許子文 徐浩荏 程式設計 ˇ ˇ 書面 ˇ ˇ ˇ 簡報製作 ˇ ˇ 資料收集 ˇ ˇ 修改與維護 ˇ 50