重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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程序定义抽象房间类room,类中包括房间号爱床位数是否有空调等成员变量,定义根据住宿天数计算

//1.定义抽象类Room

public abstract class Room {

//定义抽象方法

public void roomCost(int days){ };

}

//2.定义子类Single

public class Single extends Room {

private String bedNo;//定义属性床号

private Boolean isAirConditioning=true;//定义是否为空调房

private double roomPrice = 100.00;//定义非空调房基准价位属性

//计算房价方法

public void roomCost(int days){

//当是空调房进入if语句体,非空调房进入else语句体。

if(isAirConditioning){

roomPrice += days*10.00;

System.out.println("您的房间号为:"+getBedNo()+"号为空调房您的住宿费用如下:");

System.out.print(roomPrice);

System.out.print("人民币");

}else{

System.out.println("您的房间号为:"+getBedNo()+"号住宿费用如下:");

System.out.print(roomPrice);

System.out.print("人民币");

}

}

public String getBedNo() {

return bedNo;

}

public void setBedNo(String bedNo) {

this.bedNo = bedNo;

}

public double getRoomPrice() {

return roomPrice;

}

public void setRoomPrice(double roomPrice) {

this.roomPrice = roomPrice;

}

public static void main(String[] args) {

Single sg = new Single();

//给的房间为空调房

sg.isAirConditioning=true;

//给房间号值

sg.bedNo = "3102";

//执行房间计费方法

sg.roomCost(3);

}

}

java面试题:酒店预订!

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.println("是否是会员?y/n");

String H = input.next();

System.out.println("请输入入住日期:");

System.out.println("例如2009-03-16");

String in = input.next();

System.out.println("请输离开日期:");

System.out.println("例如2009-03-16");

String out = input.next();

//String in = s.substring(5,15);

//String out = s.substring(15,26);

//System.out.println(in+" "+out);

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

Calendar c1 = Calendar.getInstance();

Calendar c2 = Calendar.getInstance();

try {

c1.setTime(sdf.parse(in));

c2.setTime(sdf.parse(out));

} catch (ParseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

long time1 = c1.getTimeInMillis();

long time2 = c2.getTimeInMillis();

long tian = (time2-time1)/(1000*24*3600);

long tian1 = tian;

System.out.println("tian "+tian);

int week1 = c1.get(Calendar.DAY_OF_WEEK)-1;

//System.out.println(week1);

//int week2 = c2.get(Calendar.DAY_OF_WEEK)-1;

//System.out.println(week2);

int count = 0;

while(tian10){

if(week1 == 6 || week1==0){

count++;

}

if(week1==6){

week1 = 0;

week1--;

}

tian1--;

week1++;

}

System.out.println("count "+count);

long rujia;

long qitian;

long hanting;

if(H.equals("y")){

rujia = (tian-count)*80+count*80;

System.out.println("tian "+tian);

qitian = (tian-count)*110+count*50;

hanting = (tian-count)*100+count*40;

}else{

rujia = (tian-count)*110+count*90;

qitian = (tian-count)*160+count*60;

hanting = (tian-count)*220+count*150;

}

System.out.println("tian " + tian);

System.out.println("rujia "+rujia);

System.out.println("hanting "+hanting);

System.out.println("qitian "+qitian);

if(rujiaqitian rujiahanting){

System.out.println("如家");

}else if(qitianrujia qitianhanting){

System.out.println("七天");

}else if(hantingrujia hantingqitian){

System.out.println("汉庭");

}else if(hanting==rujia || hanting==qitian){

System.out.println("汉庭");

}else if(qitian==rujia qitianhanting){

System.out.println("七天");

}

}

我没怎么测试 自己测测吧 还有一些约束用户输入啥的 严谨性什么的


分享名称:java中酒店房间代码 酒店常用代码
文章URL:http://cqcxhl.cn/article/hhpsji.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP