数据库连接类:DBHelp
package DBHelp;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBHelp {
/**驱动程序名*/
private static final String driver = "com.mysql.jdbc.Driver";
//访问数据库
private static final String url = "jdbc:mysql://localhost:3306/food_db?"
+ "useUnicode=true&characterEncoding=UTF8";//防止乱码出现
/**MySQL配置时的用户名*/
private static final String user = "root";
//MySQL配置时的密码
private static final String password = "443650890";
//声明Connection对象
private static Connection con = null;
/**
* 连接数据库
* @return 返回Connection对象
* */
public static Connection mysqlConn() {
try {
Class.forName(driver); //加载驱动程序
/**1.getConnection()方法,连接MySQL数据库!!*/
con = (Connection) DriverManager.getConnection(url,user,password);
} catch (ClassNotFoundException e) {
System.out.println("加载驱动失败!");
e.printStackTrace();
} catch (SQLException e) {
System.out.println("连接数据库异常!");
e.printStackTrace();
}
return con;
}
}
消费信息类:ConsumInfo
package impl;
/**消费信息类ConsumInfo*/
public class ConsumInfo {
/**通话时长*/
int talkTime;
/**短信条数*/
int smsCount;
/**上网流量*/
int flow;
/**套餐月资费*/
double price;
public int getTalkTime() {
return talkTime;
}
public void setTalkTime(int talkTime) {
this.talkTime = talkTime;
}
public int getSmsCount() {
return smsCount;
}
public void setSmsCount(int smsCount) {
this.smsCount = smsCount;
}
public int getFlow() {
return flow;
}
public void setFlow(int flow) {
this.flow = flow;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public ConsumInfo() {
super();
// TODO Auto-generated constructor stub
}
public ConsumInfo(int talkTime, int smsCount, int flow, double price) {
super();
this.talkTime = talkTime;
this.smsCount = smsCount;
this.flow = flow;
this.price = price;
}
}
嗖移动卡类:MobileCard
package impl;
import impl_ServicePackge.ServicePackge;
/**嗖嗖移动卡类MobileCard*/
public class MobileCard {
/**卡号*/
String cardNumber;
/**用户名*/
String userName;
/**密码*/
String passWord;
/**所属套餐*/
ServicePackge serPackge;
/**当月消费金额*/
double consumAmount;
/**账户余额*/
double money ;
/**当月实际通话时长*/
int realTalkTims;
/**当月实际发短信条数*/
int realSMSCount;
/**当月实际上网流量*/
int realFlow;
public String getCardNumber() {
return cardNumber;
}
public void setCardNumber(String cardNumber) {
this.cardNumber = cardNumber;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public ServicePackge getSerPackge() {
return serPackge;
}
public void setSerPackge(ServicePackge serPackge) {
this.serPackge = serPackge;
}
public double getConsumAmount() {
return consumAmount;
}
public void setConsumAmount(double consumAmount) {
this.consumAmount = consumAmount;
}
public double getMoney() {
return money;
}
public void setMoney(double money) {
this.money = money;
}
public int getRealTalkTims() {
return realTalkTims;
}
public void setRealTalkTims(int realTalkTims) {
this.realTalkTims = realTalkTims;
}
public int getRealSMSCount() {
return realSMSCount;
}
public void setRealSMSCount(int realSMSCount) {
this.realSMSCount = realSMSCount;
}
public int getRealFlow() {
return realFlow;
}
public void setRealFlow(int realFlow) {
this.realFlow = realFlow;
}
public MobileCard(String cardNumber, String userName, String passWord, ServicePackge serPackge,
double consumAmount, double money, int realTalkTims, int realSMSCount, int realFlow) {
this.cardNumber = cardNumber;
this.userName = userName;
this.passWord = passWord;
this.serPackge = serPackge;
this.consumAmount = consumAmount;
this.money = money;
this.realTalkTims = realTalkTims;
this.realSMSCount = realSMSCount;
this.realFlow = realFlow;
}
public MobileCard() {
}
/**注册成功后显示信息的方法*/
public void showMege(){
System.out.println("卡号:"+this.cardNumber+"用户名:"+this.userName+"当前余额:"
+this.money+"元。&