课程设计报告

课程设计报告,第1张

概述基于Android的移动点餐系统设计与实现1.系统需求分析1.1用例分析Uml图如图1.1所示                              图1.1  1.2数据逻辑模型移动点餐系统E-r图如图1.2所示                          图1.22 基于AndroID的移动点餐系统设计与实现

1.系统需求分析

1.1用例分析

Uml图如图1.1所示

 

   

                          图1.1

 

 

1.2数据逻辑模型

移动点餐系统E-r图如图1.2所示

 

                         图1.2

2系统总体设计

系统总体设计图如图1.3所示

     

                        图1.3

 

 

在使用移动点餐系统的时候是要求先注册的,按照提示输入用户名,密码,电话,地址方可进行注册,在注册成功之后就可以进行登录,登录后就可以使用图上功能。自行进行点餐环节或外卖环节,进入点餐界面或外卖界面进行菜品的选择,完毕后进行提交。还可对订单信息和个人信息进行查询。

 

3系统数据库设计

根据前面E-r图设计出实现系统功能所需要的数据库表的结构,并以表格的形式列出每一个数据库表的表结构,即字段名、类型、长度、小数位数、是否主键、索引、是否允许为空、说明等。

                        dish(菜品表)

字段名

数据类型

长度

主键

索引

外键

可空

说明

ID

Varcha

10

 

菜品ID

name

Char

10

 

菜品名

imgname

Varchar

10

 

菜品图像名

Price

Varchar

10

 

菜品价格

 

4系统详细设计

 

 

 

 

1

注册

用户名,密码,电话,地址

向数据库中插入一个新的管理员用户

成功则转到登录页面失败则转到添加页面

2  2

 

登录

用户名和密码

根据输入用户名从数据库中找一个同名的用户并且进行密码比对

成功则跳转到 *** 作页面,失败就转到登录页面

 3

   

点餐和外卖

进入界面即可

 

进行点餐

 

提交

 

 

 

 

 

5系统实现(关键代码)

5.1注册界面

通过输入用户名,密码,电话,地址进行注册。

 

 

 Xml代码

<TextVIEw

        androID:ID="@+ID/textVIEw1"

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content"

        androID:layout_gravity="center_horizontal"

        androID:layout_margintop="30dp"

        androID:text="用户注册"

        androID:textSize="25sp" />

 

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw2"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="用 户 名:" />

        <EditText

            androID:ID="@+ID/etRegisterUserID"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30" >

            <requestFocus />

        </EditText>

    </linearLayout>

 

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw3"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="用户密码:" />

 

        <EditText

            androID:ID="@+ID/etRegisterUserPsword"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30"

            androID:inputType="textPassword" >

 

            <requestFocus />

        </EditText>

    </linearLayout>

 

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw4"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="确认密码:" />

 

        <EditText

            androID:ID="@+ID/etRegisterUserAffirmPsword"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30"

            androID:inputType="textPassword" >

 

            <requestFocus />

        </EditText>

    </linearLayout>

 

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw5"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="电话号码:" />

 

        <EditText

            androID:ID="@+ID/etRegisterUserMobilePhone"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30"

            androID:inputType="phone" >

 

            <requestFocus />

        </EditText>

    </linearLayout>

        

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw6"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="送餐地址:" />

        <EditText

            androID:ID="@+ID/etRegisterUserAddress"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30" >

            <requestFocus />

        </EditText>

    </linearLayout>

    

    <linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content" 

        androID:layout_margintop="10dp"

        androID:layout_gravity="center"

        androID:orIEntation="horizontal">

        <button

            androID:ID="@+ID/btnRegister"

            androID:layout_wIDth="100dp"

            androID:layout_height="wrap_content"

            androID:text=" 注  册 " />

        <button

            androID:ID="@+ID/btnCancel"

            androID:layout_wIDth="100dp"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text=" 取  消 " />

    </linearLayout>

    </linearLayout>

Java代码

package edu.cqut.MobileOrderFood;

import androID.net.Uri;

import androID.os.Bundle;

import androID.app.Activity;

import androID.content.Intent;

import androID.vIEw.Menu;

import androID.vIEw.VIEw;

import androID.Widget.*;

public class Registeractivity extends Activity {

public EditText metID, metPsword, MetaffirmPsword, metPhone, Metaddress;

@OverrIDe

protected voID onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentVIEw(R.layout.activity_register);

 

metID = (EditText)findVIEwByID(R.ID.etRegisterUserID);

metPsword = (EditText)findVIEwByID(R.ID.etRegisterUserPsword);

MetaffirmPsword = (EditText)findVIEwByID(R.ID.etRegisterUserAffirmPsword);

metPhone = (EditText)findVIEwByID(R.ID.etRegisterUserMobilePhone);

Metaddress = (EditText)findVIEwByID(R.ID.etRegisterUserAddress);

button btnOK = (button)findVIEwByID(R.ID.btnRegister);

button btnCancel = (button)findVIEwByID(R.ID.btnCancel);

 

button.OnClickListener mybtnListener = new button.OnClickListener()

{

@OverrIDe

public voID onClick(VIEw v) {

switch (v.getID())

{

case R.ID.btnCancel:

finish();

break;

case R.ID.btnRegister:

String strPsword = metPsword.getText().toString();

String strAffirmPsword = MetaffirmPsword.getText().toString();

if (strPsword.equals(strAffirmPsword))

{

 

Uri info = Uri.parse("用户注册信息");

Intent intentUserInfo = new Intent(null, info);

intentUserInfo.putExtra("user", metID.getText().toString());

intentUserInfo.putExtra("password", metPsword.getText().toString());

intentUserInfo.putExtra("phone", metPhone.getText().toString());

intentUserInfo.putExtra("address", Metaddress.getText().toString());

setResult(RESulT_OK, intentUserInfo);

finish();

}

else

{

Toast.makeText(Registeractivity.this,

"两次密码输入不一致,请重新输入密码!", Toast.LENGTH_LONG).show();

//清空密码输入框

metPsword.setText("");

MetaffirmPsword.setText("");

//让密码输入框获得焦点

metPsword.setFocusable(true);

metPsword.setFocusableIntouchMode(true);

metPsword.requestFocus();

}

}

 

}

};

 

btnOK.setonClickListener(mybtnListener);

btnCancel.setonClickListener(mybtnListener);

}

 

@OverrIDe

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.register, menu);

return true;

}

}

5.2登录界面

注册后输入正确的用户名,密码,进行登录。

       

         

 Xml代码

 <linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content" 

        androID:layout_margin="5dp"

        androID:layout_gravity="center_horizontal"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw2"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:text="用  户  名:" />

        <EditText

            androID:ID="@+ID/etLoginUserID"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:ems="8" >

            <requestFocus />

        </EditText>

</linearLayout>

<linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content" 

        androID:layout_margin="5dp"

        androID:layout_gravity="center_horizontal"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw3"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:text="用户密码:" />

        <EditText

            androID:ID="@+ID/etLoginUserPswrod"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:ems="8"

            androID:inputType="textPassword">

        </EditText>

</linearLayout>

<linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content" 

androID:layout_gravity="center_horizontal"

        androID:orIEntation="horizontal">

        <button

            androID:ID="@+ID/btnRegister"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_weight="1"

            androID:text="注  册 " />

        <button

            androID:ID="@+ID/btnlogin"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_weight="1"

            androID:text="登  录 " />

        <button

            androID:ID="@+ID/btnCancel"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_weight="1"

            androID:text="取  消 " />

    </linearLayout>

</linearLayout>

 

 

Java代码

package edu.cqut.MobileOrderFood;

 

import androID.app.Dialog;

import androID.content.Context;

import androID.vIEw.VIEw;

import androID.Widget.*;

 

public class LoginDialog extends Dialog

{

public enum buttonID {button_NONE, button_OK, button_CANCEL, button_REGISTER};

public String mUserID=null; //用户名

public String mPsword=null; //用户密码

public Boolean mIsHoldUserID=false; //是否记住用户名

public buttonID mBtnClicked=buttonID.button_NONE;//指示哪个按钮被点击

 

public EditText mdtUserID = null;

public button mbtnLogin=null;

public button mbtnRegister=null;

 

public LoginDialog(Context context) {

super(context);

setContentVIEw(R.layout.login);

this.setTitle("用户登录");

setCancelable(true);

 

mdtUserID = (EditText)findVIEwByID(R.ID.etLoginUserID);

final EditText dtPsword = (EditText)findVIEwByID(R.ID.etLoginUserPswrod);

    mbtnLogin = (button)findVIEwByID(R.ID.btnlogin);

button btnCancel = (button)findVIEwByID(R.ID.btnCancel);

mbtnRegister = (button)findVIEwByID(R.ID.btnRegister);

 

button.OnClickListener buttonListener=new button.OnClickListener(){

@OverrIDe

public voID onClick(VIEw v) {

switch (v.getID()){

case R.ID.btnlogin:

mUserID = mdtUserID.getText().toString();

mPsword = dtPsword.getText().toString();

mBtnClicked = buttonID.button_OK;

break;

case R.ID.btnRegister:

mBtnClicked = buttonID.button_REGISTER;

break;

case R.ID.btnCancel:

mBtnClicked = buttonID.button_CANCEL;

break;

}

dismiss();

}

};

mbtnLogin.setonClickListener(buttonListener);

btnCancel.setonClickListener(buttonListener);

mbtnRegister.setonClickListener(buttonListener);

}

 

//使dtUserID控件显示用户名

public voID displayUsername(String name)

{

mdtUserID.setText(name);

}

}

5.3点餐界面

 

Xml代码

<tableRow

        androID:ID="@+ID/dishhead"

        androID:layout_wIDth="match_parent"

androID:layout_height="wrap_content">

<TextVIEw  

androID:layout_wIDth="wrap_content"

androID:layout_height="wrap_content" 

androID:textcolor="#000000"

androID:textSize="20sp"

androID:gravity="center"

androID:text="编号"/>

<TextVIEw

    androID:layout_height="wrap_content"

    androID:layout_wIDth="wrap_content"

    androID:textcolor="#000000"

    androID:textSize="20sp" 

    androID:gravity="center"

    androID:layout_marginBottom="4dp"

     androID:layout_marginleft="10dp"

     androID:layout_weight="2"

    androID:text="菜品"/>

<TextVIEw

    androID:layout_wIDth="wrap_content"

    androID:layout_height="wrap_content"

    androID:textcolor="#000000"

    androID:textSize="20sp" 

    androID:text="价格"

    androID:layout_marginleft="5dp"

    androID:gravity="center"

    androID:layout_weight="1"/>

    </tableRow>

    

<ListVIEw

    androID:layout_wIDth="fill_parent"   

        androID:layout_height="wrap_content"   

        androID:ID="@+ID/ListVIEwCainpin"  />  

</linearLayout>

Java代码

package edu.cqut.MobileOrderFood;

 

public class dish

{

public int mID = -1;     

public String mname;

public int mImage;

public String mImagename;

public float mPrice;

}

 

 

 

6系统测试

本次课设所用的开发环境为
开发技术:sqlITE、AndroID Application Project
数据库:sqlITE
开发工具:sqlITE、Eclipse

6.1系统测试

测试app能否在手机或电脑模拟器中正常运行。测试数据库能否顺利连接。测试注册,登录能否正常进行。测试点餐系统能否正常使用。测试外卖系统能否正常使用。测试个人中心系统能否正常使用。

 

 

 

 

 

 

6.2测试结果

 

App完成后又对其进行了重新的测试,各项功能均正常,测试结果图如下。

 

 

   

 

     

     

 

    

 

 

 

 

 

 

 

 

 

    

 

 

    

 

 

 

 

7.总结

 

经过两个礼拜的学习,研究和开发,终于按时完成了课设。通过这个课设,我认识到理论跟实际还是有很大的差别,对安卓的知识进行了进一步的了解,激发了自己对安卓的兴趣。虽然过程中遇到了很多困难,但是在同学的帮助下一一克服。通过不断的发现问题和解决问题的过程,使自己有了很大的提高,并且得到了宝贵的经验。在以后的学习里,会更加努力,细心。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

附件

布局文件

 

    <linearLayout

        androID:ID="@+ID/linearLayout1"

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" >

        <ImageVIEw

            androID:ID="@+ID/homeImageVIEw"

            androID:layout_wIDth="match_parent"

            androID:layout_height="wrap_content"

            androID:cropTopadding="true"

            androID:scaleType="centerCrop"

            androID:src="@drawable/diancanlogo" />

    </linearLayout>

 

    <tableLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content"

        androID:layout_alignleft="@+ID/linearLayout1"

        androID:layout_below="@+ID/linearLayout1" >

        <tableRow

            androID:ID="@+ID/tableRow1"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content" >

    <Imagebutton

        androID:ID="@+ID/imgBtnRest"

        androID:layout_height="wrap_content"

        androID:layout_weight="1"

        androID:layout_margintop="15dp"

        androID:background="@drawable/diancan"/>

    <Imagebutton

        androID:ID="@+ID/imgBtnTakeout"

        androID:layout_height="wrap_content"

        androID:layout_weight="1"

        androID:layout_margintop="15dp"

        androID:layout_marginleft="5dp"

        androID:background="@drawable/waimai"/>

        </tableRow>

        <tableRow

            androID:ID="@+ID/tableRow2"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content" >

    <Imagebutton

        androID:ID="@+ID/imgBtnUserInfo"

        androID:layout_height="wrap_content"

        androID:layout_weight="1"

        androID:layout_margintop="5dp"

        androID:background="@drawable/gerenzhongxin"/>

    <Imagebutton

        androID:ID="@+ID/imgBtnLogin"

        androID:layout_height="wrap_content"

        androID:layout_weight="1"

        androID:layout_margintop="5dp"

        androID:layout_marginleft="5dp"

        androID:visibility="visible"

        androID:background="@drawable/denglu"/>

    <Imagebutton

        androID:ID="@+ID/imgBtnlogout"

        androID:layout_height="wrap_content"

        androID:layout_weight="1"

        androID:layout_margintop="5dp"

        androID:layout_marginleft="5dp"

        androID:visibility="gone"

        androID:background="@drawable/zhuxiao"/>

        </tableRow>

    <Imagebutton

        androID:ID="@+ID/imgBtnMyOrderes"

        androID:layout_height="wrap_content"

        androID:layout_margintop="5dp"

        androID:background="@drawable/wodedingdan"/>

    </tableLayout>

</relativeLayout>

 

 

    <tableRow

        androID:ID="@+ID/dishhead"

        androID:layout_wIDth="match_parent"

androID:layout_height="wrap_content">

<TextVIEw  

androID:layout_wIDth="wrap_content"

androID:layout_height="wrap_content" 

androID:textcolor="#000000"

androID:textSize="20sp"

androID:gravity="center"

androID:text="编号"/>

<TextVIEw

    androID:layout_height="wrap_content"

    androID:layout_wIDth="wrap_content"

    androID:textcolor="#000000"

    androID:textSize="20sp" 

    androID:gravity="center"

    androID:layout_marginBottom="4dp"

     androID:layout_marginleft="10dp"

     androID:layout_weight="2"

    androID:text="菜品"/>

<TextVIEw

    androID:layout_wIDth="wrap_content"

    androID:layout_height="wrap_content"

    androID:textcolor="#000000"

    androID:textSize="20sp" 

    androID:text="价格"

    androID:layout_marginleft="5dp"

    androID:gravity="center"

    androID:layout_weight="1"/>

    </tableRow>

    

<ListVIEw

    androID:layout_wIDth="fill_parent"   

        androID:layout_height="wrap_content"   

        androID:ID="@+ID/ListVIEwCainpin"  />  

</linearLayout>

 

    <tableRow

        androID:ID="@+ID/Orderedhead"

        androID:layout_wIDth="match_parent"

androID:layout_height="wrap_content">

<TextVIEw  

androID:layout_wIDth="120dp"

androID:layout_height="wrap_content" 

androID:textcolor="#000000"

androID:textSize="20sp"

androID:gravity="center"

androID:text="菜名"/>

<TextVIEw

    androID:layout_wIDth="wrap_content"

    androID:layout_height="wrap_content"

    androID:textcolor="#000000"

    androID:textSize="20sp" 

    androID:text="单价"

    androID:layout_weight="1"/>

<TextVIEw

    androID:layout_wIDth="wrap_content"

    androID:layout_height="wrap_content"

    androID:textcolor="#000000"

    androID:textSize="20sp" 

    androID:text="数量"

    androID:layout_weight="1"/>

<TextVIEw

    androID:ID="@+ID/sum"

    androID:layout_wIDth="wrap_content" 

androID:layout_height="wrap_content"

    androID:textcolor="#000000"

    androID:text="合计"

    androID:layout_weight="1"

    androID:textSize="20sp" />        

    </tableRow>

    

    <ListVIEw

        androID:ID="@+ID/OrderedListvIEw"

        androID:layout_wIDth="fill_parent"

        androID:layout_height="wrap_content"

        androID:layout_below="@ID/Orderedhead"/>

    

    <tableRow

        androID:ID="@+ID/OrderEnd"

        androID:layout_wIDth="match_parent"

androID:layout_height="wrap_content"

androID:layout_margintop="15dp"

androID:layout_below="@ID/OrderedListvIEw">

<TextVIEw  

androID:layout_wIDth="150dp"

androID:layout_height="wrap_content" 

androID:textcolor="#000000"

androID:textSize="20sp"

androID:gravity="center"

androID:text="总    价"/>

<TextVIEw

    androID:layout_wIDth="wrap_content"

    androID:layout_height="wrap_content"

    androID:textSize="20sp" 

    androID:layout_weight="1"/>

<TextVIEw

    androID:layout_wIDth="wrap_content"

    androID:layout_height="wrap_content"

    androID:textSize="20sp" 

    androID:layout_weight="1"/>

<TextVIEw

    androID:ID="@+ID/ordertotalprice"

    androID:layout_wIDth="wrap_content" 

androID:layout_height="wrap_content"

    androID:textcolor="#000000"

    androID:layout_weight="1"

    androID:gravity="center"

    androID:textSize="20sp" />        

    </tableRow>

    

    <linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content"

        androID:layout_below="@ID/OrderEnd"

        androID:layout_centerHorizontal="true"

        androID:layout_margintop="15dp" >       

    <button

        androID:ID="@+ID/submit_cancel"

        androID:layout_wIDth="100dp"

        androID:layout_height="wrap_content"

        androID:text="取消"/>   

    <button

        androID:ID="@+ID/submit_ok"

        androID:layout_wIDth="100dp"

        androID:layout_height="wrap_content"

        androID:text="提交"/>  

    </linearLayout>

 

</relativeLayout>

              

 

 <TextVIEw

        androID:ID="@+ID/textVIEw1"

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content"

        androID:layout_gravity="center_horizontal"

        androID:layout_margintop="30dp"

        androID:text="用户注册"

        androID:textSize="25sp" />

 

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw2"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="用  户  名:" />

        <EditText

            androID:ID="@+ID/etRegisterUserID"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30" >

            <requestFocus />

        </EditText>

    </linearLayout>

 

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw3"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="用户密码:" />

 

        <EditText

            androID:ID="@+ID/etRegisterUserPsword"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30"

            androID:inputType="textPassword" >

 

            <requestFocus />

        </EditText>

    </linearLayout>

 

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw4"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="确认密码:" />

 

        <EditText

            androID:ID="@+ID/etRegisterUserAffirmPsword"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30"

            androID:inputType="textPassword" >

 

            <requestFocus />

        </EditText>

    </linearLayout>

 

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw5"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="电话号码:" />

 

        <EditText

            androID:ID="@+ID/etRegisterUserMobilePhone"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30"

            androID:inputType="phone" >

 

            <requestFocus />

        </EditText>

    </linearLayout>

        

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw6"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="送餐地址:" />

        <EditText

            androID:ID="@+ID/etRegisterUserAddress"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30" >

            <requestFocus />

        </EditText>

    </linearLayout>

    

    <linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content" 

        androID:layout_margintop="10dp"

        androID:layout_gravity="center"

        androID:orIEntation="horizontal">

        <button

            androID:ID="@+ID/btnRegister"

            androID:layout_wIDth="100dp"

            androID:layout_height="wrap_content"

            androID:text=" 注  册 " />

        <button

            androID:ID="@+ID/btnCancel"

            androID:layout_wIDth="100dp"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text=" 取  消 " />

    </linearLayout>

    

 

</linearLayout>

 

  <linearLayout

        androID:orIEntation="vertical"

        androID:layout_wIDth="fill_parent"

        androID:layout_height="fill_parent"

        androID:padding="5dp">

        <TabWidget

            androID:ID="@androID:ID/tabs"

            androID:layout_wIDth="fill_parent"

            androID:layout_height="wrap_content">            

        </TabWidget>

 

        <FrameLayout

            androID:ID="@androID:ID/tabcontent"

            androID:layout_wIDth="fill_parent"

     androID:layout_height="fill_parent"

     androID:padding="3dp">            

        </FrameLayout>

       </linearLayout>

</TabHost>

 

    <TextVIEw

        androID:ID="@+ID/textVIEw1"

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content"

        androID:layout_gravity="center_horizontal"

        androID:layout_margintop="30dp"

        androID:text="用户信息"

        androID:textSize="25sp" />

 

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw2"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="用  户  名:" />

        <TextVIEw

            androID:ID="@+ID/textUserID"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30" >

        </TextVIEw>

    </linearLayout>

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw3"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="登录密码:" />

        <EditText

            androID:ID="@+ID/etLoginPswrod"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30" >

            <requestFocus />

        </EditText>

    </linearLayout>

    <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw6"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="电话号码:" />

        <EditText

            androID:ID="@+ID/etUserPhone"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30" >

            <requestFocus />

        </EditText>

    </linearLayout>

     <linearLayout

        androID:layout_wIDth="match_parent"

        androID:layout_height="wrap_content" 

        androID:layout_margin="10dp"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw7"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginleft="30dp"

            androID:text="送餐地址:" />

        <EditText

            androID:ID="@+ID/etUserAddress"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_marginRight="30dp"

            androID:ems="30" >

            <requestFocus />

        </EditText>

</linearLayout>

<linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content"

        androID:layout_margintop="10dp"

        androID:layout_gravity="center"

        androID:orIEntation="horizontal" >

        <button

            androID:ID="@+ID/btnModify"

            androID:layout_wIDth="120dp"

            androID:layout_height="wrap_content"

 

            androID:gravity="center"

            androID:text="修改 " />

        <button

            androID:ID="@+ID/btnReturn"

            androID:layout_wIDth="120dp"

            androID:layout_height="wrap_content"

androID:layout_marginleft="15dp"

            androID:gravity="center"

            androID:text="返回" />

</linearLayout>

</linearLayout>

 

<linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content" 

        androID:layout_margin="5dp"

        androID:layout_gravity="center_horizontal"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw2"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:text="用  户  名:" />

        <EditText

            androID:ID="@+ID/etLoginUserID"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:ems="8" >

            <requestFocus />

        </EditText>

    </linearLayout>

 

    <linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content" 

        androID:layout_margin="5dp"

        androID:layout_gravity="center_horizontal"

        androID:orIEntation="horizontal">

        <TextVIEw

            androID:ID="@+ID/textVIEw3"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:text="用户密码:" />

        <EditText

            androID:ID="@+ID/etLoginUserPswrod"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:ems="8"

            androID:inputType="textPassword">

        </EditText>

    </linearLayout>

 

    <linearLayout

        androID:layout_wIDth="wrap_content"

        androID:layout_height="wrap_content" 

androID:layout_gravity="center_horizontal"

        androID:orIEntation="horizontal">

        <button

            androID:ID="@+ID/btnRegister"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_weight="1"

            androID:text="注  册 " />

        <button

            androID:ID="@+ID/btnlogin"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_weight="1"

            androID:text="登  录 " />

        <button

            androID:ID="@+ID/btnCancel"

            androID:layout_wIDth="wrap_content"

            androID:layout_height="wrap_content"

            androID:layout_weight="1"

            androID:text="取  消 " />

    </linearLayout>

 

</linearLayout>

 

<linearLayout   

    androID:layout_wIDth="wrap_content"   

    androID:layout_height="wrap_content"

    androID:layout_gravity="center"

    androID:orIEntation="horizontal">   

<TextVIEw

     androID:layout_wIDth="wrap_content"   

     androID:layout_height="wrap_content"   

     androID:text="数量"/>  

<button

     androID:layout_wIDth="40dp"

     androID:layout_height="wrap_content"

     androID:ID="@+ID/btnSub"

     androID:text="-"/>

<TextVIEw

     androID:layout_wIDth="40dp"

     androID:layout_height="wrap_content"

     androID:ID="@+ID/tvOrderNum"

     androID:gravity="center"

     androID:text="1"/>

<button

     androID:layout_wIDth="30dp"

     androID:layout_height="wrap_content"

     androID:ID="@+ID/btnAdd"

     androID:text="+"/>       

</linearLayout>

<linearLayout   

    androID:layout_wIDth="wrap_content"   

    androID:layout_height="wrap_content"

    androID:layout_gravity="center"

    androID:orIEntation="horizontal">

<button

    androID:layout_wIDth="wrap_content"

    androID:layout_height="wrap_content"

    androID:text="确  定"

    androID:ID="@+ID/order_dialog_ok"/>

<button

    androID:layout_wIDth="wrap_content"

    androID:layout_height="wrap_content"

    androID:text="取  消"

    androID:ID="@+ID/order_dialog_cancel"/>

</linearLayout>

</linearLayout>  

Java文件(部分)

1.dish

package edu.cqut.MobileOrderFood;

public class dish

{

public int mID = -1;      

public String mname;

public int mImage;

public String mImagename;

public float mPrice;

}

2.dished

package edu.cqut.MobileOrderFood;

import java.util.ArrayList;

public class dishes

{

public ArrayList<dish> mdishes;  

public int GetdishQuantity()

{

return mdishes.size();

}

public dish GetdishbyIndex(int i)

{

return mdishes.get(i);

}

public dish Getdishbyname(String dishname)

{

int s = mdishes.size();

for (int i=0; i<s; i++) {

dish thedish = mdishes.get(i);

if (dishname.equals(thedish.mname)) {

return thedish;

}

}

return null;

}

}

Login

package edu.cqut.MobileOrderFood;

import androID.app.Dialog;

import androID.content.Context;

import androID.vIEw.VIEw;

import androID.Widget.*;

public class LoginDialog extends Dialog

{

public enum buttonID {button_NONE, button_OK, button_CANCEL, button_REGISTER};

public String mUserID=null;

public String mPsword=null;

public Boolean mIsHoldUserID=false;

public buttonID mBtnClicked=buttonID.button_NONE;

public EditText mdtUserID = null;

public button mbtnLogin=null;

public button mbtnRegister=null;

public LoginDialog(Context context) {

super(context);

setContentVIEw(R.layout.login);

this.setTitle("用户登录");

setCancelable(true);

 

mdtUserID = (EditText)findVIEwByID(R.ID.etLoginUserID);

final EditText dtPsword = (EditText)findVIEwByID(R.ID.etLoginUserPswrod);

    mbtnLogin = (button)findVIEwByID(R.ID.btnlogin);

button btnCancel = (button)findVIEwByID(R.ID.btnCancel);

mbtnRegister = (button)findVIEwByID(R.ID.btnRegister);

 

button.OnClickListener buttonListener=new button.OnClickListener(){

@OverrIDe

public voID onClick(VIEw v) {

switch (v.getID()){

case R.ID.btnlogin:

mUserID = mdtUserID.getText().toString();

mPsword = dtPsword.getText().toString();

mBtnClicked = buttonID.button_OK;

break;

case R.ID.btnRegister:

mBtnClicked = buttonID.button_REGISTER;

break;

case R.ID.btnCancel:

mBtnClicked = buttonID.button_CANCEL;

break;

}

dismiss();

}

};

mbtnLogin.setonClickListener(buttonListener);

btnCancel.setonClickListener(buttonListener);

mbtnRegister.setonClickListener(buttonListener);

}

public voID displayUsername(String name)

{

mdtUserID.setText(name);

}

}

4.MyApplication

ackage edu.cqut.MobileOrderFood;

import java.util.ArrayList;

import androID.app.Application;

import androID.content.Context;

public class MyApplication extends Application

{

MyUser g_user;

ShopPingCart g_cart;

ArrayList<Order> g_orders;

// dishes g_dishes;  

    public String g_ip="";     

    public String g_http_ip="";

    public int g_communiMode = 1;

    public int g_objPort = 35885;

    Context g_context;    

    public DBAdapter g_dbAdepter = null;

String g_imgdishimgPath="AndroID/data/edu.cqut.mobileorderfood/img";

}

MyUser

package edu.cqut.MobileOrderFood;

public class MyUser

{

    public String mUserID = "";

    public String mSeatname = "";

public String mPassword = "";  

public String mUserphone = "";

    public String mUseraddress = "";

public Boolean mIslogined=false;

}

Order

package edu.cqut.MobileOrderFood;

public class Order

{

public int mID = -1;

public ShopPingCart mOrderItems;

public String mOrderTime;

 

public Order(String userID)

{

mOrderItems = new ShopPingCart(userID);

}

 

6.DBAdapter

private final Context context;

private DBOpenHelper dbOpenHelper;

 

public DBAdapter(Context _context) {

    context = _context;

  }

 public voID close() {

  if (db != null){

  db.close();

  db = null;

  }

}

 

  public voID open() throws sqliteException {  

  dbOpenHelper = new DBOpenHelper(context, DB_name, null, DB_VERSION);

  try {

  db = dbOpenHelper.getWritableDatabase();

  }

  catch (sqliteException ex) {

  db = dbOpenHelper.getReadableDatabase();

  }   

}

  

 

  public long insert(dish dish) {

    ContentValues newValues = new ContentValues();

    newValues.put(KEY_ID, dish.mID);

    newValues.put(KEY_name, dish.mname);

    newValues.put(KEY_imgname, dish.mImagename);

    newValues.put(KEY_PRICE, dish.mPrice);

    

    return db.insert(DB_table, null, newValues);

  }

 

 

  public ArrayList<dish> queryAllData() {  

  Cursor results =  db.query(DB_table, new String[] { KEY_ID, KEY_name, KEY_imgname, KEY_PRICE},

  null, null, null, null, null);

  return ConvertTodishes(results);   

  }

  

  public dish queryOneData(long ID) {  

  Cursor results =  db.query(DB_table, new String[] { KEY_ID, KEY_name, KEY_imgname,

  KEY_PRICE}, KEY_ID+"="+ID, null, null, null, null);

  return ConertTodish(results);   

  }

  

  private dish ConertTodish(Cursor cursor)

  {

  int resultCounts = cursor.getCount();

  if (resultCounts == 0 || !cursor.movetoFirst()){

  return null;

  }

  dish thedish = new dish();

  thedish.mID = cursor.getInt(0);

  thedish.mname = cursor.getString(cursor.getColumnIndex(KEY_name));

  thedish.mImagename = cursor.getString(cursor.getColumnIndex(KEY_imgname));

  thedish.mPrice = cursor.getfloat(cursor.getColumnIndex(KEY_PRICE));

 

  return thedish;   

  }

  

  private ArrayList<dish> ConvertTodishes(Cursor cursor){

  int resultCounts = cursor.getCount();

  if (resultCounts == 0 || !cursor.movetoFirst()){

  return null;

  }

  ArrayList<dish> dishes = new ArrayList<dish>();

  for (int i = 0 ; i<resultCounts; i++){

  dish thedish = new dish();

  thedish.mID = cursor.getInt(0);

  thedish.mname = cursor.getString(cursor.getColumnIndex(KEY_name));

  thedish.mImagename = cursor.getString(cursor.getColumnIndex(KEY_imgname));

  thedish.mPrice = cursor.getfloat(cursor.getColumnIndex(KEY_PRICE));

  dishes.add(thedish);

  

  cursor.movetoNext();

  }   

  return dishes;

  }

  

  public long deleteallData() {

  return db.delete(DB_table, null, null);

  }

 

  public long deleteOneData(long ID) {

  return db.delete(DB_table,  KEY_ID + "=" + ID, null);

  }

 

  public long updateOneData(long ID , dish dish){

  ContentValues updateValues = new ContentValues();   

  updateValues.put(KEY_name, dish.mname);

  updateValues.put(KEY_imgname, dish.mImagename);

  updateValues.put(KEY_PRICE, dish.mPrice);

  

  return db.update(DB_table, updateValues,  KEY_ID + "=" + ID, null);

  }

  

 

  private static class DBOpenHelper extends sqliteOpenHelper

  {

 

  public DBOpenHelper(Context context, String name, CursorFactory factory, int version) {

    super(context, name, factory, version);

  }

 

  private static final String DB_CREATE = "create table " +

    DB_table + " (" + KEY_ID + " integer primary key, " +

    KEY_name+ " text not null, " + KEY_imgname+ " text," + KEY_PRICE + " float);";

 

  @OverrIDe

  public voID onCreate(sqliteDatabase _db) {

    _db.execsql(DB_CREATE);

  }

 

  @OverrIDe

  public voID onUpgrade(sqliteDatabase _db, int _oldVersion, int _newVersion) {     

    _db.execsql("DROP table IF EXISTS " + DB_table);

    onCreate(_db);

  }

}

  

 

    public boolean Filldishtable(ArrayList<dish> dishes)

    {

     int s = dishes.size();

     for (int i=0; i<s; i++)

     {

     dish thedish = dishes.get(i);

     if (insert(thedish) == -1)

     return false;

     }

     return true;

    }

    

  

public ArrayList<Map<String, Object>> getdishData()

{

 

ArrayList<dish> dishes = queryAllData();

ArrayList<Map<String, Object>> fooddata=new ArrayList<Map<String,Object>>();  

 

int s = dishes.size();

for (int i=0; i<s; i++) {

dish thedish = dishes.get(i);

Map<String, Object> map = new HashMap<String, Object>();

map.put("dishID", thedish.mID);

map.put("image", thedish.mImagename);

map.put("Title", thedish.mname);

map.put("price", thedish.mPrice);

fooddata.add(map);

}

return fooddata;

}

 

总结

以上是内存溢出为你收集整理的课程设计报告全部内容,希望文章能够帮你解决课程设计报告所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1070080.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存