成都创新互联网站制作重庆分公司

java酒店入住时间代码 java酒店入住时间代码是多少

java 编程中显示日期和时间的代码

可以直接通过jdk基本方法,获取到当前的时间

台江网站建设公司成都创新互联,台江网站设计制作,有大型网站制作公司丰富经验。已为台江上1000+提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的台江做网站的公司定做!

Date date= new Date();//创建一个时间对象,获取到当前的时间

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置时间显示格式

String str = sdf.format(date);//将当前时间格式化为需要的类型

System.out.println(str);//输出结果

结果为:2015-11-06 13:53:54(实时)。

求用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面试题:酒店预订!

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

package jcon.com.help;

/**

* 顾客类

* @author Jcon

*

*/

public class Customer {

private String name;

private String date;

private int days;

public Customer(String name, String date, int days) {

super();

this.name = name;

this.date = date;

this.days = days;

}

@Override

public String toString() {

return "Customer [name=" + name + ", date=" + date + ", days=" + days

+ "]";

}

}

package jcon.com.help;

/**

* 房间类

* @author Jcon

*

*/

public class Room {

private int number;

private Customer customer;

private boolean isUse = false;//开始房间是空的

public int getNumber() {

return number;

}

public void setNumber(int number) {

this.number = number;

}

public Customer getCustomer() {

return customer;

}

public void setCustomer(Customer customer) {

this.customer = customer;

}

public boolean getIsUse() {

return isUse;

}

public void setIsUse(boolean isUse) {

this.isUse = isUse;

}

}

package jcon.com.help;

import java.util.HashMap;

import java.util.Map;

/**

* 酒店类

* @author Jcon

*

*/

public class Hote {

private  int cengShu; //层楼

private  int roomNumber; //每层楼房间数

public static MapInteger,Room rooms = new HashMapInteger, Room(); //key房间号,value房间信息

public Hote(int cengShu,int roomNumber) {

this.cengShu = cengShu;

this.roomNumber = roomNumber;

init();

}

private void init(){//初始化,把每个房间信息装入到Map

for (int i = 1; i = this.cengShu; i++) {

for (int j = 1; j = this.roomNumber; j++) {

String roomNumber = i+""+j;

if (j 10) {

roomNumber = i+"0"+j;

}

rooms.put(Integer.valueOf(roomNumber), new Room());

}

}

}

}

package jcon.com.help;

/**

* 酒店管理类

* @author Jcon

*

*/

public class Manager {

private Hote hote = new Hote(1, 15);

//通过房间号查找

public void findRoomByNumber(int roomNumber){

Room room = hote.rooms.get(roomNumber);

if (room == null) {

System.out.println("你要查找的房间号不存在,请确认输入房间号是否正确!");

}else {

if (room.getIsUse()){

System.out.println("房间:"+roomNumber+"已有人入住,入住人信息:"+room.getCustomer());

}else {

System.out.println("房间"+roomNumber+"还未有人入住");

}

}

}

//查找所有空房间

public void findNullRoom(){

for (Integer key : hote.rooms.keySet()) {

Room room = hote.rooms.get(key);

if (room.getIsUse() == false) {

System.out.println("空房间号:"+key);

}

}

}

//入住

public void in(int roomNumber,Customer customer){

Room room = hote.rooms.get(roomNumber);

room.setCustomer(customer);

room.setIsUse(true);

room.setNumber(roomNumber);

hote.rooms.put(roomNumber, room);

System.out.println("房间:"+roomNumber+"办理入住,住房人信息:"+customer);

}

//退房

public void out(int roomNumber){

Room room = hote.rooms.get(roomNumber);

room.setCustomer(null);

room.setIsUse(false);

hote.rooms.put(roomNumber, room);

System.out.println("房间:"+roomNumber+"办理退房");

}

public static void main(String[] args) {

Manager manager = new Manager();

//客人来开房,先看看有没有空房间

manager.findNullRoom();

//看到还有很多空房子,客人要开115号房

Customer customer = new Customer("小白", "03月25日入住", 3);//登记客人信息

manager.in(115, customer);//开房

//查看开房后当前房间信息

manager.findRoomByNumber(115); //115号房的

manager.findNullRoom(); //所有空房间的

//住了3天客人要退房

manager.out(115);

//查看退房后当前房间信息

manager.findRoomByNumber(115); //115号房的

manager.findNullRoom(); //所有空房间的

}

}


当前标题:java酒店入住时间代码 java酒店入住时间代码是多少
标题来源:http://cxhlcq.com/article/doeheji.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部