java订房系统代码 java酒店预订系统
java作业程序,急求
package test;
10余年的南漳网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销的优势是能够根据用户设备显示端的尺寸不同,自动调整南漳建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联公司从事“南漳网站设计”,“南漳网站推广”以来,每个客户项目都认真落实执行。
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写的网上订房程序 要有酒店类 房间类 客户类 订房记录类 模拟一个人订房操作
酒店类
package fdsa;
public class Hotel {
private String hotelID;
private String hotelName;
private String hoteladdess;
public String getHotelID() {
return hotelID;
}
public void setHotelID(String hotelID) {
this.hotelID = hotelID;
}
public String getHotelName() {
return hotelName;
}
public void setHotelName(String hotelName) {
this.hotelName = hotelName;
}
public String getHoteladdess() {
return hoteladdess;
}
public void setHoteladdess(String hoteladdess) {
this.hoteladdess = hoteladdess;
}
public String getHotelPhone() {
return hotelPhone;
}
public void setHotelPhone(String hotelPhone) {
this.hotelPhone = hotelPhone;
}
private String hotelPhone;
}
客户类
public class Client{
private String clientName;
private String clientID;
public String getClientName() {
return clientName;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public String getClientID() {
return clientID;
}
public void setClientID(String clientID) {
this.clientID = clientID;
}
}
房间类
public class Room{
private String roomID;
private Hotel hotelID;
public String getRoomID() {
return roomID;
}
public void setRoomID(String roomID) {
this.roomID = roomID;
}
public Hotel getHotelID() {
return hotelID;
}
public void setHotelID(Hotel hotelID) {
this.hotelID = hotelID;
}
public String getRoomAmount() {
return roomAmount;
}
public void setRoomAmount(String roomAmount) {
this.roomAmount = roomAmount;
}
private String roomAmount;
}
网站标题:java订房系统代码 java酒店预订系统
标题网址:http://myzitong.com/article/ddieoos.html