网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

退房信息的java代码,退房信息的java代码是什么

Java 求改一段小程序,不用GUI

package com;

成都地区优秀IDC服务器托管提供商(成都创新互联公司).为客户提供专业的西信服务器托管,四川各地服务器托管,西信服务器托管、多线服务器托管.托管咨询专线:18980820575

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.ArrayList;

import java.util.Calendar;

import java.util.Date;

import java.util.List;

public class Customer

{

public enum Type{

University

}

private long customerId; //客户ID

private String name; //客户姓名

private String address; //客户常用住址

private String telNo; //客户手机号

private long bookDate; //预定日期毫秒数

private long checkInDate; //客户入住日期毫秒数

private long checkOutDate; //客户退房日期毫秒数

private Type type; //客户类型

/** 检查指定客户是否是周末预定*/

public static final boolean checkWeekend(Customer c)

{

Calendar cal = Calendar.getInstance();

cal.setTimeInMillis(c.bookDate);

int x = cal.get(Calendar.WEDNESDAY);

return x == Calendar.SATURDAY || x == Calendar.SUNDAY;

}

/** 计算指定客户账单*/

public static final double calcBill(Customer c)

{

switch (c.type)

{

case University:

return calcDuration(c) * 100;

default:

return 0.0;

}

}

/** 计算住店天数*/

public static final int calcDuration(Customer c)

{

return Math.round((c.checkOutDate - c.checkInDate) / (float)(1000 * 60 * 60 * 24));

}

public static final void printQueryedCustomer(long customerId, ListCustomer cs)

{

for(Customer c : cs)

{

if(c.customerId == customerId)

{

System.out.println("name:" + c.name);

System.out.println("address:" + c.address);

System.out.println("telNo:" + c.telNo);

System.out.println("checkInDate:" + c.checkInDate);

System.out.println("checkOutDate:" + c.checkOutDate);

System.out.println("duration:" + calcDuration(c));

}

}

}

private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");

private static final long fromDateString(String date)

{//将日期字符串转换成毫秒数

try

{

return sdf.parse(date).getTime();

} catch (ParseException e)

{

e.printStackTrace();

return 0;

}

}

private static final String toDateString(long millsec)

{//将毫秒数转换成日期字符串

return sdf.format(new Date(millsec));

}

public Customer(Type type)

{

customerId = System.currentTimeMillis(); //以对象创建时刻为对象唯一标识

this.type = type;

}

public long getCustomerId()

{

return customerId;

}

public Type getType()

{

return type;

}

public String getName()

{

return name;

}

public void setName(String name)

{

this.name = name;

}

public String getAddress()

{

return address;

}

public void setAddress(String address)

{

this.address = address;

}

public String getTelNo()

{

return telNo;

}

public void setTelNo(String telNo)

{

this.telNo = telNo;

}

public String getBookDate()

{

return toDateString(bookDate);

}

/**

* @param bookDate 比如"2014-01-11 13:55"

*/

public void setBookDate(String bookDate)

{

this.bookDate = fromDateString(bookDate);

}

public String getCheckInDate()

{

return toDateString(checkInDate);

}

/**

* @param bookDate 比如"2014-01-11 13:55"

*/

public void setCheckInDate(String checkInDate)

{

this.checkInDate = fromDateString(checkInDate);

}

public String getCheckOutDate()

{

return toDateString(checkOutDate);

}

/**

* @param bookDate 比如"2014-01-11 13:55"

*/

public void setCheckOutDate(String checkOutDate)

{

this.checkOutDate = fromDateString(checkOutDate);

}

public static void main(String[] args)

{

ListCustomer list = new ArrayListCustomer();

Customer c1 = new Customer(Type.University);

c1.setName("张三");

c1.setAddress("xxx");

c1.setTelNo("000");

c1.setCheckInDate("2014-02-22 12:00");

c1.setCheckOutDate("2014-02-24 12:00");

list.add(c1);

long id = c1.getCustomerId();

Customer c2 = new Customer(Type.University);

c2.setName("李四");

c2.setAddress("PPP");

c2.setTelNo("333");

c2.setBookDate("2014-03-25 10:17");

list.add(c2);

long idx = c2.getCustomerId();

System.out.println("客户" + idx + (checkWeekend(c2)?"是":"不是") + "周末预定");

System.out.println("#############################################");

printQueryedCustomer(id, list);

System.out.println("#############################################");

System.out.println("客户" + id + "的账单是" + calcBill(c1));

}

}

如何用java编写比较完善的宾馆管理系统

package room;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import com.njit.HelloHotel;

import com.wind.util.DbUtil;

import java.io.UnsupportedEncodingException;

import java.sql.*;

public class roomadd extends JFrame

{

private JTextField roomno,roomcost,roomstatus,roomtype;

//private JComboBox roomtype;

private JButton ok,cancel,return1,chakan;

private Container contain;

public roomadd()

{

super();

this.setSize(350,450);

this.setTitle("添加信息");

this.setLocationRelativeTo(getOwner()); //居中

//设置组件布局

Container contain=getContentPane();

contain.setLayout(new BoxLayout(contain,BoxLayout.Y_AXIS));

//添加组件

JPanel cont=new JPanel (new GridLayout(4,2));

//添加组件

/*cont.add(new JLabel("客房类型"));

roomtype=new JComboBox();

roomtype.addItem("单人间");

roomtype.addItem("双人间");

roomtype.addItem("三人房");

roomtype.addItem("四人间");

cont.add(roomtype);*/

cont.add(new JLabel("客房号"));

roomno=new JTextField(10);

cont.add(roomno);

cont.add(new JLabel("房间类型"));

roomtype=new JTextField(10);

cont.add(roomtype);

cont.add(new JLabel("客房价格"));

roomcost=new JTextField(10);

cont.add(roomcost);

cont.add(new JLabel("客房状态"));

roomstatus=new JTextField(10);

cont.add(roomstatus);

//按钮

JPanel cont1=new JPanel(new FlowLayout());

ok=new JButton("添加");

cancel=new JButton("取消");

chakan=new JButton("查看");

return1=new JButton("返回");

cont1.add(ok);

cont1.add(cancel);

cont1.add(chakan);

cont1.add(return1);

contain.add(cont);

contain.add(cont1);

//注册监听器

ok.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent evt){

//ok事件处理

DbUtil util = new DbUtil();

Connection con=null;

try {

con = (Connection) util.getCon();

} catch (Exception e2) {

e2.printStackTrace();

}

String sql="insert into room values(?,?,?,?)";

PreparedStatement pstmt = null;

try {

pstmt = (PreparedStatement)con.prepareStatement(sql);

} catch (SQLException e2) {

e2.printStackTrace();

}

try {

pstmt.setString(1,roomno.getText());

pstmt.setString(2,roomtype.getText());

pstmt.setString(3,roomcost.getText());

pstmt.setString(4,roomstatus.getText());

pstmt.executeUpdate();

} catch (SQLException e1) {

e1.printStackTrace();

}

JOptionPane.showMessageDialog(null, " 注册成功!");

}

});

//查看添加的预订信息

chakan.addActionListener(new ActionListener(){

private JTable table;

public void actionPerformed(ActionEvent e) {

if(e.getSource()==chakan){

Connection con = null;

ResultSet rs=null;

DbUtil util = new DbUtil();

String[][] a;

String[] name = { "", "", "", ""};

int row = 0;

try {

con = (Connection) util.getCon();

}

catch (Exception e1) {

e1.printStackTrace();

}

try {

String roomno = null;

rs=(ResultSet) util.sroom(con, roomno);

} catch (Exception e1) {

e1.printStackTrace();

}

try {

while(rs.next()){

row++;

}

a = new String[row + 1][4];

a[0][0] = " 客房号";

a[0][1] = " 客房类型";

a[0][2] = " 客房价格 ";

a[0][3] = " 客房状态";

table = new JTable(a,name);

int i = 0;

String roomno = null;

rs=(ResultSet)util.sroom(con,roomno);

while (rs.next()) {

// 往表中填充查询到的数据

i++;

int j = 0;

table.setValueAt(new String(rs.getString("roomno").getBytes("ISO-8859-1"),"GBK") + "", i, j);

table.setValueAt(new String(rs.getString("roomtype").getBytes("ISO-8859-1"),"GBK") + "", i, ++j);

table.setValueAt(new String(rs.getString("roomcost").getBytes("ISO-8859-1"),"GBK") + "", i, ++j);

table.setValueAt(new String(rs.getString("roomstatus").getBytes("ISO-8859-1"),"GBK") + "", i, ++j);

}

} catch (SQLException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (UnsupportedEncodingException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (Exception e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

JFrame b5=new JFrame("顾客预订信息");

b5.setLayout(new BorderLayout());

b5.add(table);

b5.setBounds(200, 200, 500, 300);

b5.setVisible(true);

b5.setResizable(true);

b5.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}

}

});

cancel.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

System.exit(0);

}

});

return1.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

HelloHotel hello=new HelloHotel();

hello.setVisible(true);

dispose();

}

});

pack();

}

public static void main(String[] args) {

roomadd w=new roomadd();

w.setVisible(true);

}

}

大概改改就可以是你的需要的了

谁能帮我写一个java 程序 要求如下

包名可修改成你自己的

============================================

package wineshop;

//记录类测试类

public class TestTackeDown {

public static void main(String[] args) {

// 新建一个酒店

Wineshop wineshop = new Wineshop(36687, "天上人间大酒店", "河北腹地");

// 来了一个客户

Client client = new Client("奥巴马", "1109111202478296",

"2012/12/12 8:00", "没想过要退房");

// 客户来了新开一个房间

Room room = new Room(688, "总统套房-单人", wineshop.getId(), 8898);

// 订房记录

new TackeDown(wineshop, room, client);

}

}

// 酒店类

class Wineshop {

// 酒店编号

private int id;

// 酒店名字

private String name;

// 酒店地址

private String adress;

public Wineshop(int id, String name, String adress) {

this.id = id;

this.name = name;

this.adress = adress;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getAdress() {

return adress;

}

public void setAdress(String adress) {

this.adress = adress;

}

}

// 房间类

class Room {

// 房间号码

private int roomId;

// 房间类型

private String type;

// 酒店编号

private int wineshopNumber;

// 金额

private int price;

public Room(int roomId, String type, int wineshopNumber, int price) {

this.roomId = roomId;

this.type = type;

this.wineshopNumber = wineshopNumber;

this.price = price;

}

public int getRoomId() {

return roomId;

}

public void setRoomId(int roomId) {

this.roomId = roomId;

}

public String getType() {

return type;

}

public void setType(String type) {

this.type = type;

}

public int getWineshopNumber() {

return wineshopNumber;

}

public void setWineshopNumber(int wineshopNumber) {

this.wineshopNumber = wineshopNumber;

}

public int getPrice() {

return price;

}

public void setPrice(int price) {

this.price = price;

}

}

// 客户类

class Client {

// 客户姓名

private String name;

// 客户身份证号码

private String identityCard;

// 客户入住时间

private String intoroomtime;

// 客户退房时间

private String outroomtime;

public Client(String name, String identityCard, String intoroomtime,

String outroomtime) {

this.name = name;

this.identityCard = identityCard;

this.intoroomtime = intoroomtime;

this.outroomtime = outroomtime;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getIdentityCard() {

return identityCard;

}

public void setIdentityCard(String identityCard) {

this.identityCard = identityCard;

}

public String getIntoroomtime() {

return intoroomtime;

}

public void setIntoroomtime(String intoroomtime) {

this.intoroomtime = intoroomtime;

}

public String getOutroomtime() {

return outroomtime;

}

public void setOutroomtime(String outroomtime) {

this.outroomtime = outroomtime;

}

}

// 订房记录类

class TackeDown {

public TackeDown(Wineshop wineshop, Room room, Client client) {

// 打印酒店名字

System.out.println("酒店名字:" + wineshop.getName());

// 次房间的酒店编号

System.out.println("此房间的酒店编号:" + room.getWineshopNumber());

// 打印房间ID

System.out.println("房间ID:" + room.getRoomId());

// 打印房间类型

System.out.println("房间类型:" + room.getType());

// 打印酒店地址

System.out.println("酒店地址:" + wineshop.getAdress());

// 打印客户身份证号码

System.out.println("身份证号码:" + client.getIdentityCard());

// 打印订房者姓名

System.out.println("订房者姓名" + client.getName());

// 打印定房者入住时间

System.out.println("入住时间:" + client.getIntoroomtime());

// 打印订房者退房时间

System.out.println("退房时间:" + client.getOutroomtime());

}

}

==============================================================

运行结果:

-----------------------------------------

酒店名字:天上人间大酒店

此房间的酒店编号:36687

房间ID:688

房间类型:总统套房-单人

酒店地址:河北腹地

身份证号码:1109111202478296

订房者姓名奥巴马

入住时间:2012/12/12 8:00

退房时间:没想过要退房

客房管理系统,用java,sql

首先得确定一下你用b/s还是c/s

再确定选什么书吧,

很多的

求大神帮忙写下这个java程序

import java.util.Scanner;

public class T1 {

static String [][] rooms = new String[12][10];

static {

for (int i=0;i12;i++)

for (int j=0;j10;j++)

rooms[i][j] = "EMPTY";

}

public static void main(String argv[]) {

System.out.println("XXX酒店管理程序加载完毕,请输入指令:");

Scanner sca = new Scanner(System.in);

while (true) {

String comm = sca.next();

if (comm.equalsIgnoreCase("Search")) {

search();

} else if (comm.equalsIgnoreCase("in")) {

System.out.println("输入客人姓名:");

String name = sca.next();

inRoom(name);

} else if (comm.equalsIgnoreCase("out")) {

System.out.println("输入客人房间号:");

int room = sca.nextInt();

outRoom(room/100, room%100);

} else if (comm.equalsIgnoreCase("exit")) {

System.out.println("退出程序");

break;

} else {

System.out.println("无效的命令,请重新输入!");

}

}

sca.close();

}

private static void outRoom(int i, int j) {

if (i1 || i12 || j1 || j10) {

System.out.println("输入错误,请重新输入");

} else   {

if (rooms[i-1][j-1].equalsIgnoreCase("empty")) {

System.out.printf("%02d%02d 并没有客人入住\n", i, j);

} else {

System.out.printf("OUT %02d%02d: %02d%02d房间退房,客人姓名:%s\n", i, j, i, j, rooms[i-1][j-1]);

rooms[i-1][j-1] = "EMPTY";

return;

}

}

}

private static void inRoom(String name) {

for (int i=0;i12;i++) {

for (int j=0;j10;j++) {

if (rooms[i][j].equalsIgnoreCase("EMPTY")) {

rooms[i][j] = name;

System.out.printf("IN  %02d%02d  %s  :  姓名为%s的客人入住%02d%02d房间\n", i+1, j+1, name, name, i+1, j+1);

return;

}

}

}

}

private static void search() {

System.out.println("入住房间信息:");

System.out.println("---------------------------");

for (int i=0;i12;i++) {

for (int j=0;j10;j++) {

if (!rooms[i][j].equalsIgnoreCase("EMPTY")) {

System.out.printf("ROOM %02d%02d 客人:%s\n", i+1, j+1, rooms[i][j]);

}

}

}

System.out.println("---------------------------");

}

}

java作业程序,急求

package test;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.HashMap;

import java.util.Map;

public class Test {

public static void main(String[] args) throws IOException{  

MapString, Room rooms =initRooms();

BufferedReader ctrl=new BufferedReader(new InputStreamReader(System.in));

getRoomState(rooms);

boolean exit = true;

while(exit){

println("");

print("菜单: ");

print(" 1:订房");

print(" 2:退房");

print(" 3:查询");

print(" 4:退出");

println("");

print(" 请输入:");

String num =ctrl.readLine();

cls();

switch (num) {

     case "1":

          print("房间号:");

          String rid = ctrl.readLine();

          print("帐号:");

          String user = ctrl.readLine();

          print("密码:");

          String pwd = ctrl.readLine();

          print("住天数:");

          String day = ctrl.readLine();

          Room r = rooms.get(rid);

          if(r==null){

              println("没有此房间");

          }else{

              r.setDay(Integer.parseInt(day));

              r.setName(user);

              r.setPwd(pwd);

              rooms.put(r.getrId(),r);

              println("订房成功!!");

              getRoomState(rooms);

          }

         break;

     case "2":

         print("帐号:");

          String user2 = ctrl.readLine();

          print("密码:");

          String pwd2 = ctrl.readLine();

          Room r2 =getRoowByUserAndPwd(rooms,user2,pwd2);

          if(r2==null){

              println("你没有订房!!");

          }else{

             r2.setName("");

             r2.setPwd("");

             r2.setDay(0);

             rooms.put(r2.getrId(),r2);

             println("退订成功");

             getRoomState(rooms);

          }

         break;

     case "3":

          print("帐号:");

          String user3 = ctrl.readLine();

          print("天数:");

          String day3 = ctrl.readLine();

          Room r3 =getRoowByUserAndDay(rooms,user3,day3);

          if(r3==null){

              println("你没有订房!!");

          }else{

             println(r3.toString());

          }

         break;

     case "4":exit = false ;break;

 }

getRoomState(rooms);

}

}

private static void getRoomState(MapString, Room rooms) {

println("房间情况:");

for (Room r : rooms.values()) {

   println("房号:"+r.getrId()+"=" + r.getPrice()+" 状态:"+r.isEmptyRoom());

}

}

private static Room getRoowByUserAndDay(MapString, Room rooms,String user,String day) {

for (Room r : rooms.values()) {

   if(r.getName().equals(user) day.equals(r.getDay()+""))

       return r;

}

return null;

}

private static Room getRoowByUserAndPwd(MapString, Room rooms,String user,String pwd) {

for (Room r : rooms.values()) {

   if(r.getName().equals(user) pwd.equals(r.getPwd()+""))

       return r;

}

return null;

}

/**

* 初始化房间

*/

private static MapString, Room initRooms() {

MapString, Room result = new HashMapString, Room();

result.put("8001", new Room("8001",100.0));

result.put("8002", new Room("8002",100.0));

result.put("8003", new Room("8003",100.0));

result.put("8004", new Room("8004",200.0));

result.put("8005", new Room("8005",200.0));

result.put("8006", new Room("8006",200.0));

result.put("8007", new Room("8007",300.0));

result.put("8008", new Room("8008",300.0));

result.put("8009", new Room("8009",300.0));

return result;

}

public static void cls() throws IOException{

Runtime.getRuntime().exec("clear");

}

public static void println(Object str){

System.out.println(str);

}

public static void print(Object str){

System.out.print(str);

}

}

class Room{

private String rId="";

private String name="";

private String pwd="";

private int day=0;

private double price=0.0;

public String isEmptyRoom(){

return this.name.equals("")?"空房间":"已出租";

}

public Room(String rId, double price) {

this.rId = rId;

this.price = price;

}

@Override

public String toString() {

return "房号=" + rId + ", 用户=" + name + ", 天数=" + day

     + ", 租金=" + price + ", 总金额=" + (price*day);

}

public Room(String name, String pwd, int day) {

this.name = name;

this.pwd = pwd;

this.day = day;

}

public Room() {

}

public String getrId() {

return rId;

}

public void setrId(String rId) {

this.rId = rId;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getPwd() {

return pwd;

}

public void setPwd(String pwd) {

this.pwd = pwd;

}

public int getDay() {

return day;

}

public void setDay(int day) {

this.day = day;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

}

比较粗糙将就


本文名称:退房信息的java代码,退房信息的java代码是什么
网页链接:http://bjjierui.cn/article/hspcoh.html

其他资讯