日期:2014-05-20  浏览次数:20659 次

请高手帮帮忙,急急!!!
我老师要求做一段手机订票程序。本人在网上搞了一段,但是还缺数据与服务器交互、连接的片段。请高手帮忙补完,谢谢了。
程序如下:


package   demo;
import   javax.microedition.io.HttpConnection;
import   javax.microedition.lcdui.Alert;
import   javax.microedition.lcdui.AlertType;
import   javax.microedition.lcdui.Command;
import   javax.microedition.lcdui.CommandListener;
import   javax.microedition.lcdui.Display;
import   javax.microedition.lcdui.Displayable;
import   javax.microedition.lcdui.Form;
import   javax.microedition.lcdui.List;
import   javax.microedition.lcdui.TextBox;
import   javax.microedition.lcdui.TextField;
import   javax.microedition.midlet.MIDlet;
import   javax.microedition.io.*;

import   com.sun.cldc.i18n.StreamReader;
public   class   asktickets   extends   MIDlet   implements
CommandListener{
private   Display   display;
private   TextField   date,startstation,stopstation;
private   List   type;
private   TextBox   textinf;
private   Form   questionform,resultform;
private   Command   cmdnext;
private   Command   cmdexit;            
private   Command   cmdconf;
private   Command   cmdcanc;
private   Command   cmdsend;
private   Alert   alert1;  
public   asktickets   ()   {
super   ();
display   =Display.getDisplay(this);
startstation   =   new   TextField   ( "起点站输入 ", " ",   20,   0)   ;
stopstation   =   new   TextField   ( "终点站输入 ", " ",   20,   0)   ;
date   =   new   TextField   ( "乘车日期输入(格式如20020312)   : ", " "   ,20,   0)   ;
String[]     typestr   =   { "硬座 ", "软卧 ", "硬卧上铺 ", "硬卧中铺 ", "硬卧下铺 "};
type   =   new   List( "请选择乘坐席别:   ",   List.   EXCLUSIVE,typestr,   null)   ;
textinf   =   new   TextBox( "您要查询的信息为 ",   null,   60,   0)   ;
questionform   =   new   Form   ( "查询输入:   ")   ;   //查询窗
questionform.append   (   startstation)   ;   //起点站输入框
questionform.append   (   stopstation)   ;//终点站输入框
questionform.append   (   date)   ;   //乘车日期输入框
questionform.addCommand   (   cmdnext)   ;
questionform.addCommand   (   cmdexit)   ;
questionform.setCommandListener(   this)   ;
type.addCommand   (   cmdconf)   ;   //乘坐席别无选择
type.addCommand   (   cmdcanc)   ;
type.setCommandListener(   this)   ;
textinf.   addCommand   (   cmdsend)   ;   //查询输入的总信息回显框
textinf.   addCommand   (   cmdcanc)   ;
textinf.   setCommandListener(   this)   ;
resultform   =   new   Form   ( "查询结果 ")   ;   //查询结果框
resultform.   addCommand   (   cmdexit)   ;
resultform.   setCommandListener(   this)   ;
}
public   void   startApp   (   )
{  
display.setCurrent(questionform)   ;   }
public   void   pauseApp   (   )   {   }
public   void   destroyApp   (   boolean   unconditional)   {   }
public   void   commandAction   (Command   c,Displayable   d   )