找個(gè)簡(jiǎn)單的:
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名與空間、網(wǎng)頁(yè)空間、營(yíng)銷(xiāo)軟件、網(wǎng)站建設(shè)、同仁網(wǎng)站維護(hù)、網(wǎng)站推廣。
import?java.util.Scanner;
public?class?a1{
public?static?void?main(String[]?args){
Scanner?s?=?new?Scanner(System.in);//接受客戶鍵盤(pán)輸入,在命令行中,回車(chē)結(jié)束
System.out.println(?"酒店管理系統(tǒng)"?);
Hotel?h?=?new?Hotel();
System.out.println(?h?);
h.print();
while?(true){
System.out.println(?"請(qǐng)輸入房間編號(hào)"?);
//聲明變量,用于接受控制臺(tái)輸入數(shù)據(jù)
String?no?=?s.next();
//預(yù)訂房間
h.order(no);
h.print();
}
}
}
class?Room{
//房間號(hào)
private?String?no;
//房間類(lèi)型
private?String?type;
//是否被占用
private?boolean?isUse;
public?Room(){//默認(rèn)調(diào)用
super();
}
public?Room(String?no,String?type,boolean?isUse){
super();
this.no?=?no;
this.type?=?type;
this.isUse?=?isUse;
}
public?String?getNo(){
return?no;
}
public?void?setNo(String?no){
this.no?=?no;
}
public?String?getType(){
return?type;
}
public?void?setType(String?type){
this.type?=?type;
}
public?boolean?isUse(){
return?isUse;
}
public?void?setUse(boolean?isUse){
this.isUse?=?isUse;
}
public?String?toString(){??//聲明輸出結(jié)果格式
return?"["?+?no?+?","?+?type?+?","?+?(isUse?"占用":"空閑")?+?"]";
}
}
class?Hotel{
Room?rooms[][];
public?Hotel(){
rooms?=?new?Room[5][4];//旅館有五層,每層四個(gè)房間
for(int?i=0;?i??rooms.length;?++i){//外層for循環(huán)是循環(huán)層,內(nèi)存循環(huán)是循環(huán)的每層的房間
for(int?j=0;?j??rooms[i].length;?++j){
if?(i?==?0?||?i?==?1)?{
//后面加個(gè)空字符串,是自動(dòng)數(shù)據(jù)類(lèi)型轉(zhuǎn)換,這樣前面的數(shù)字會(huì)自動(dòng)變成數(shù)字型字符串;
rooms[i][j]?=?new?Room((i+1)*100+j+1?+""?,?"標(biāo)準(zhǔn)間",false);
}
if?(i?==?2?||?i?==?3)?{
rooms[i][j]?=?new?Room((i+1)*100+j+1?+""?,?"雙人間",false);?
}
if?(i?==?4)?{
rooms[i][j]?=?new?Room((i+1)*100+j+1?+""?,?"豪華間",false);?
}
}
}
}
//對(duì)外提供房間列表的打印方式
public?void?print(){
for(int?i=0;?i??rooms.length;?++i){
for(int?j=0;?j??rooms[i].length;?++j){
System.out.print(?rooms[i][j]?+?"?"?);
}
//換行
System.out.println(??);
}
}
//提供旅館對(duì)外預(yù)定方式
public?void?order(String?no){
for(int?i=0;?i??rooms.length;?++i){
for(int?j=0;?j??rooms[i].length;?++j){
if?(rooms[i][j].getNo().equals(no))?{
//把對(duì)象的成員數(shù)據(jù)封裝,通過(guò)成員方法訪問(wèn)
//1?成員變量的訪問(wèn)方式rooms[i][j].no;
//2?成員方法的訪問(wèn)方式
rooms[i][j].setUse(true);
return;
}
}
}
}
}
帶數(shù)據(jù)庫(kù)的就算了
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("是否是會(huì)員?y/n");
String H = input.next();
System.out.println("請(qǐng)輸入入住日期:");
System.out.println("例如2009-03-16");
String in = input.next();
System.out.println("請(qǐng)輸離開(kāi)日期:");
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("七天");
}
}
我沒(méi)怎么測(cè)試 自己測(cè)測(cè)吧 還有一些約束用戶輸入啥的 嚴(yán)謹(jǐn)性什么的
你可以在CSDN下載頻道去搜 Java 酒店管理系統(tǒng) 或 圖書(shū)館 這樣的關(guān)鍵字,那里經(jīng)常有人分享代碼模版之類(lèi)