Skip to content

Latest commit

ย 

History

History
683 lines (585 loc) ยท 30.9 KB

README.md

File metadata and controls

683 lines (585 loc) ยท 30.9 KB

header

๐ŸŽ‡ ๋ถˆ์ข€๊บผ์กฐ

๐Ÿจ Spring_6๊ธฐ A๋ฐ˜ 1์กฐ ํ˜ธํ…” ์˜ˆ์•ฝ ํ”„๋กœ๊ทธ๋žจ ๐Ÿจ

๐Ÿ“ ํ”„๋กœ๊ทธ๋žจ ์š”๊ตฌ์‚ฌํ•ญ

  1. ํ˜ธํ…”์€ ์—ฌ๋Ÿฌ ๊ฐ์‹ค, ๋ณด์œ  ์ž์‚ฐ์„ ๊ฐ€์ง
  2. ๊ฐ์‹ค์€ ๊ฐ์‹ค ๋‹น ํ•˜๋ฃจ์— ํ•œ ์‚ฌ๋žŒ๋งŒ ์˜ˆ์•ฝ ๊ฐ€๋Šฅ
  3. ๊ฐ์‹ค์€ ํฌ๊ธฐ, ์ˆ™๋ฐ•๋น„๋ฅผ ๊ฐ€์ง
  4. ์˜ˆ์•ฝ์€ ๊ฐ์‹ค, ๊ณ ๊ฐ ์ด๋ฆ„, ๊ณ ๊ฐ ์ „ํ™”๋ฒˆํ˜ธ, ์˜ˆ์•ฝ ๋‚ ์งœ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Œ
    • ์„ ํƒ) ์ „ํ™” ๋ฒˆํ˜ธ ์ •๊ทœ ํ‘œํ˜„์‹ (XXX - XXXX - XXXX)
    • ์˜ˆ์•ฝ ๋‚ ์งœ - ISO 8601 ํ˜•์‹์œผ๋กœ ์กฐํ•ฉ๋œ UTC ๋‚ ์”จ ๋ฐ ์‹œ๊ฐ„ (ex.2016-10-27T17:13:40+00:00)
  5. ๊ณ ๊ฐ์€ ์ด๋ฆ„, ์ „ํ™”๋ฒˆํ˜ธ, ์†Œ์ง€๊ธˆ์„ ๊ฐ€์ง
    • ๊ณ ๊ฐ์˜ ์†Œ์ง€๊ธˆ๋ณด๋‹ค ๋น„์‹ผ ๋ฐฉ์˜ ๊ฒฝ์šฐ ์˜ˆ์•ฝ ๋ถˆ๊ฐ€
  6. ํ˜ธํ…”์€ ๋ชจ๋“  ์˜ˆ์•ฝ ๋ชฉ๋ก ์กฐํšŒ ๊ฐ€๋Šฅ
  7. ๊ณ ๊ฐ์€ ์ž์‹ ์˜ ์˜ˆ์•ฝ ๋ชฉ๋ก ์กฐํšŒ ๊ฐ€๋Šฅ
    • ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋กœ ์˜ˆ์•ฝ ๋‚ด์—ญ ์กฐํšŒ
  8. ๊ณ ๊ฐ์€ ์ž์‹ ์˜ ์˜ˆ์•ฝ ์ทจ์†Œ ๊ฐ€๋Šฅ
  9. ๊ณ ๊ฐ์ด ํ˜ธํ…” ์˜ˆ์•ฝ ์‹œ, ์˜ˆ์•ฝ ๋ฒˆํ˜ธ(id)๋ฅผ ๋ฐ˜ํ™˜ํ•จ(UUID ํ™œ์šฉํ•˜๊ธฐ)
    • ๊ณ ๊ฐ์ด ํ˜ธํ…” ์˜ˆ์•ฝ์— ์„ฑ๊ณตํ•˜๋ฉด ์˜ˆ์•ฝ ๋ฒˆํ˜ธ(id)๋ฅผ ๋ฐ›์Œ
    • ๊ณ ๊ฐ์ด ์˜ˆ์•ฝ ๋ชฉ๋ก ์กฐํšŒ ์‹œ, ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋„ ํ•จ๊ป˜ ์กฐํšŒ๋จ
    • ๊ณ ๊ฐ์ด ์˜ˆ์•ฝ ์ทจ์†Œ ์‹œ, ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ํ†ตํ•ด ์ž์‹ ์˜ ํŠน์ • ์˜ˆ์•ฝ ์ทจ์†Œ

๐Ÿ‘ฉโ€๐Ÿ’ป ํŒ€์› ์—ญํ• 

  • ๊ณ ํ‘ธ๋ฆ„: ์˜ˆ์•ฝ ์™„๋ฃŒ, ํ˜ธํ…”์˜ ์˜ˆ์•ฝ ๋ชฉ๋ก ์กฐํšŒ
  • ๊น€์ธ์„œ: ๊ณ ๊ฐ ์ •๋ณด ๋ฆฌํ„ด
  • ์†ก๋ณ‘๋ฏผ: ๋ฐฉ ์ •๋ณด ๋ฆฌํ„ด
  • ์‹ฌํ˜•์ฒ : ์˜ˆ์•ฝ ๊ฐ€๋Šฅํ•œ ๋ฐฉ ์กฐํšŒ
  • ์ด์ˆ˜์—ฐ: ๊ณ ๊ฐ์˜ ์˜ˆ์•ฝ ๋ชฉ๋ก ์กฐํšŒ, ์‚ญ์ œ

๐Ÿ’ป ์ถœ๋ ฅ ํ™”๋ฉด ๊ตฌ์ƒ

โ˜† ๋ถˆ์ข€๊บผ์กฐ ํ˜ธํ…”์— ์˜ค์‹  ๊ฒƒ์„ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค โ˜†

-----๋ฉ”์ธ ๋ฉ”๋‰ด-----
1. ๊ณ ๊ฐ
2. ํ˜ธํ…”
3. ์ข…๋ฃŒ
๋ฉ”๋‰ด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 

------ ๊ณ ๊ฐ ํŽ˜์ด์ง€ ------
1. ์˜ˆ์•ฝํ•˜๊ธฐ
2. ์˜ˆ์•ฝ ๋‚ด์—ญ ํ™•์ธํ•˜๊ธฐ & ์‚ญ์ œํ•˜๊ธฐ
3. ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ€๊ธฐ
๋ฉ”๋‰ด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 

------ ๊ฐ์‹ค ๋ชฉ๋ก ------
์˜ค๋Š˜์€ 2023-06-05T17:13:40+00:00 ์ž…๋‹ˆ๋‹ค.
yyyy-MM-dd ํ˜•ํƒœ๋กœ ์›ํ•˜์‹œ๋Š” ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”. ์˜ˆ: 2023-06-05
2023-06-07

๋ฐฉ ์ด๋ฆ„          | ๊ฐ€๊ฒฉ (๋งŒ ์›)
STANDARD_TWIN   | 9.0
STANDARD_DOUBLE | 9.0

------ ๊ฐ์‹ค ์ •๋ณด ์ž…๋ ฅ ------
์˜ˆ์•ฝํ•˜์‹ค ๊ฐ์‹ค์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š” ex)FAMILY_SUITE
STANDARD_TWIN

------ ๊ณ ๊ฐ ์ •๋ณด ์ž…๋ ฅ๋ฐ›๊ธฐ ------
์„ฑํ•จ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 
์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š” ex)000-0000-0000 :
์†Œ์ง€๊ธˆ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š” โ€ป1์€ 1๋งŒ์›์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. :  

์˜ˆ์•ฝ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

------ ์˜ˆ์•ฝ ์™„๋ฃŒ ํŽ˜์ด์ง€ ------
์˜ˆ์•ฝ์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
๊ณ ๊ฐ๋‹˜์˜ ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋Š” 0000000-0000-0000-0000-00000000 ์ž…๋‹ˆ๋‹ค.

------ ์˜ˆ์•ฝ ํ™•์ธ ํŽ˜์ด์ง€ ------
์„ฑํ•จ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 
์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š” ex)000-0000-0000:

"000" ๋‹˜์˜ ์˜ˆ์•ฝ ๋‚ด์—ญ (์ด 1๊ฑด)์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
000 | STANDARD_TWIN | 9.0 | 2023-06-07 | 0000000-0000-0000-0000-00000000

์˜ˆ์•ฝ ๋‚ด์—ญ์„ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?(์˜ˆ/์•„๋‹ˆ์˜ค): 

์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 0000000-0000-0000-0000-00000000

์˜ˆ์•ฝ์ด ์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

------ ํ˜ธํ…” ํŽ˜์ด์ง€ ------
๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 
1234
1. ํ˜ธํ…” ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ
2. ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ •
๋ฉ”๋‰ด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 

------ ์˜ˆ์•ฝ ๋‚ด์—ญ ๊ด€๋ฆฌ์ž ํŽ˜์ด์ง€ ------
๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 
1234

000 | STANDARD_TWIN | 9.0 | 2023-06-07 | 0000000-0000-0000-0000-00000000

3์ดˆ ํ›„ ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.

------ ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ • ํŽ˜์ด์ง€ ------
๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ˆ˜์ •ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? (์˜ˆ/์•„๋‹ˆ์˜ค): ์˜ˆ
๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋‹ค์‹œ ํ•œ ๋ฒˆ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 1234
์ˆ˜์ •ํ•  ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: 12345
๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ—‚๏ธ ํŒŒ์ผ ๊ตฌ์„ฑ

  1. Customer.java

๊ณ ๊ฐ์˜ ์ •๋ณด๋ฅผ ์ €์žฅํ•œ๋‹ค. ๊ณ ๊ฐ์˜ ์ด๋ฆ„, ์ „ํ™”๋ฒˆํ˜ธ, ์†Œ์ง€๊ธˆ ์ •๋ณด๋ฅผ ๊ฐ€์ง„๋‹ค.

  1. Room.java

๊ฐ์‹ค ์ •๋ณด๋ฅผ ์ €์žฅํ•œ๋‹ค. ๊ฐ์‹ค์˜ ํฌ๊ธฐ, ์ˆ™๋ฐ•๋น„์™€, ๊ฐ์‹ค์— ์˜ˆ์•ฝ๋œ ๋‚ ์งœ๋ฅผ ์ €์žฅํ•  ๋ฆฌ์ŠคํŠธ๋ฅผ ๊ฐ€์ง„๋‹ค.

  1. Reservation.java

์˜ˆ์•ฝ ์ •๋ณด๋ฅผ ์ €์žฅํ•œ๋‹ค. ์˜ˆ์•ฝํ•˜๋Š” ๊ฐ์‹ค, ๊ณ ๊ฐ ์ด๋ฆ„, ๊ณ ๊ฐ ์ „ํ™”๋ฒˆํ˜ธ, ์˜ˆ์•ฝ์ผ, ์˜ˆ์•ฝ๋ฒˆํ˜ธ๋ฅผ ๊ฐ€์ง„๋‹ค.

  1. Hotel.java

ํ˜ธํ…”์˜ ์ •๋ณด๋ฅผ ์ €์žฅํ•œ๋‹ค. ๊ฐ์‹ค ๋ฆฌ์ŠคํŠธ, ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ, ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์™€ ํ˜ธํ…”์˜ ์ž์‚ฐ, ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๊ฐ€์ง„๋‹ค. ๊ฐ์‹ค ์ดˆ๊ธฐํ™”, ๋ฉ”์ธ ๋ฉ”๋‰ด, ๊ณ ๊ฐ ๋ฉ”๋‰ด, ํ˜ธํ…” ๋ฉ”๋‰ด, ๊ฐ์‹ค ๋‚ด์—ญ, ๊ฐ์‹ค ์ž…๋ ฅ๋ฐ›๊ธฐ, ๊ณ ๊ฐ ์ •๋ณด ์ž…๋ ฅ๋ฐ›๊ธฐ, ์˜ˆ์•ฝํ•˜๊ธฐ, ์˜ˆ์•ฝ ๋‚ด์—ญ ์กฐํšŒ ๋ฐ ์‚ญ์ œ, ํ˜ธํ…”์—์„œ ์˜ˆ์•ฝ ๋‚ด์—ญ ์กฐํšŒ, ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ •, ์ „ํ™”๋ฒˆํ˜ธ ์ •๊ทœ์‹ ํŒ๋‹จ ๋ฉ”์†Œ๋“œ๋ฅผ ๊ฐ€์ง„๋‹ค.

  1. Main.java

main ๋ฉ”์†Œ๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. Hotel ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ , showMain() ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค.

๐Ÿช„ ์ฝ”๋“œ ๊ตฌ์„ฑ

Customer.java, Room.java, Reservation.java, Hotel.java, Main.java ์ด 5๊ฐœ์˜ ํด๋ž˜์Šค๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค.

  1. Customer.java
public class Customer {

    private String name, phone;    // ์ด๋ฆ„, ์ „ํ™”๋ฒˆํ˜ธ
    private Double cash;           // ์†Œ์ง€๊ธˆ

    public String getName() { return name; }

    public String getPhone() { return phone; }

    public Double getCash() { return cash; }

    public void setCash(Double cash) { this.cash = cash; }

    public Customer(String name, String phone, Double cash) {
        this.name = name;
        this.phone = phone;
        this.cash = cash;
    }
}

๊ณ ๊ฐ์˜ ์ด๋ฆ„๊ณผ ์ „ํ™”๋ฒˆํ˜ธ, ์†Œ์ง€๊ธˆ์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ํ•„๋“œ์™€ ๊ทธ์— ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ getter ๋ฉ”์†Œ๋“œ, cash ํ•„๋“œ๋ฅผ ์„ค์ • ๊ฐ€๋Šฅํ•œ setter ๋ฉ”์†Œ๋“œ, Customer ์ƒ์„ฑ์ž๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค.

  1. Room.java
public class Room {

    private String roomSize;                                  // ๋ฐฉ ์‚ฌ์ด์ฆˆ
    private Double roomCharge;                                // ๋ฐฉ ์š”๊ธˆ
    private List<String> dateList = new ArrayList<>();        // ์˜ˆ์•ฝ ๋‚ ์งœ ๋ฆฌ์ŠคํŠธ

    public String getRoomSize() { return roomSize; }

    public Double getRoomCharge() { return roomCharge; }

    public List<String> getDateList() { return dateList; }
    
    public void setDateList(String date) { this.dateList.add(date); }

    Room(String roomSize, Double roomCharge) {
        this.roomSize = roomSize;
        this.roomCharge = roomCharge;
    }

}

๋ฐฉ์˜ ์‚ฌ์ด์ฆˆ์™€ ๋ฐฉ์˜ ์š”๊ธˆ์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ํ•„๋“œ์™€ ์˜ˆ์•ฝ ๋‚ ์งœ๋ฅผ ๋ฆฌ์ŠคํŠธ ํ˜•ํƒœ๋กœ ์ €์žฅํ•œ๋‹ค. ๊ฐ ํ•„๋“œ์™€ ๋ฆฌ์ŠคํŠธ์— ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ getter ๋ฉ”์†Œ๋“œ๊ฐ€ ์žˆ๊ณ , dateList์— ์˜ˆ์•ฝ ๋‚ ์งœ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”์†Œ๋“œ, Room() ์ƒ์„ฑ์ž๊ฐ€ ์žˆ๋‹ค.

  1. Reservation.java
public class Reservation {

    // ๊ฐ์‹ค, ๊ณ ๊ฐ ์ด๋ฆ„, ๊ณ ๊ฐ ์ „ํ™”๋ฒˆํ˜ธ, ์ˆ™๋ฐ•์ผ, ์˜ˆ์•ฝ ๋ฒˆํ˜ธ
    private Room room; 
    private String customerName, phoneNumber, reservationDate, id;

    public Room getRoom() { return room; }

    public String getCustomerName() { return customerName; }

    public String getPhoneNumber() { return phoneNumber; }

    public String getReservationDate() { return reservationDate; }

    public String getId() { return id; }

    public Reservation(Room room, String customerName, String phoneNumber, String reservationDate) {
        this.room = room;
        this.customerName = customerName;
        this.phoneNumber = phoneNumber;
        this.reservationDate = reservationDate;
        this.id = UUID.randomUUID().toString();
    }

}

๊ฐ์‹ค๊ณผ ๊ณ ๊ฐ ์ด๋ฆ„, ๊ณ ๊ฐ ์ „ํ™”๋ฒˆํ˜ธ, ์ˆ™๋ฐ•์ผ, ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ํ•„๋“œ๋ฅผ ์ƒ์„ฑํ•˜๊ณ , ๊ฐ ํ•„๋“œ์— ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ getter ๋ฉ”์†Œ๋“œ๋ฅผ ๋งŒ๋“ค์—ˆ๊ณ , Reservation() ์ƒ์„ฑ์ž๊ฐ€ ์กด์žฌํ•œ๋‹ค.

  1. Hotel.java Hotel ํด๋ž˜์Šค ์•ˆ์— ์ฝ”๋“œ๊ฐ€ ๊ธธ์–ด, ๋Š์–ด์„œ ์„ค๋ช…์„ ์ ๊ณ ์ž ํ•œ๋‹ค.
public class Hotel {
}

์•„๋ž˜์˜ ์ฝ”๋“œ๋Š” ํ•ด๋‹น ํด๋ž˜์Šค ๋‚ด์— ์ ํ˜€์žˆ๋‹ค.

  1. ํ•„๋“œ ๋ฐ ๋ฆฌ์ŠคํŠธ
private List<Room> roomList = new ArrayList<>();                 // ๋ฐฉ ๋ฆฌ์ŠคํŠธ
private List<Reservation> reservationList = new ArrayList<>();   // ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ
private List<Customer> customerList = new ArrayList<>();         // ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ
private String asset;                                            // ํ˜ธํ…” ์ž์‚ฐ
private String password = "1234";                                // ํ˜ธํ…” ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ

ํด๋ž˜์Šค ๋‚ด์— ์ƒ์„ฑ๋œ ํ•„๋“œ ๋ฐ ๋ฆฌ์ŠคํŠธ์ด๋‹ค. ๋ฐฉ, ์˜ˆ์•ฝ, ๊ณ ๊ฐ์„ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ๋ฆฌ์ŠคํŠธ๊ฐ€ ๊ฐ๊ฐ ์กด์žฌํ•˜๊ณ , ํ˜ธํ…”์˜ ์ž์‚ฐ๊ณผ ํ˜ธํ…” ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ํ•„๋“œ๊ฐ€ ์žˆ๋‹ค.

  1. init() ๋“œ๋ฉ”์†Œ๋“œ
// ๊ฐ์‹ค ๋ฆฌ์ŠคํŠธ - CHARGE ๋‹จ์œ„ 1.0*10000
public void init() {
    roomList = Arrays.asList(
        new Room("STANDARD_TWIN", 9.0),
        new Room("STANDARD_DOUBLE", 9.0),
        new Room("STANDARD_ONDOL", 9.0),
        new Room("DELUX_TWIN", 10.0),
        new Room("DELUX_KIDSROOM", 11.0),
        new Room("DELUX_TRIPLE", 11.5),
        new Room("DELUX_FAMILY_TWIN", 13.0),
        new Room("JUNIOR_SUITE", 15.0),
        new Room("FAMILY_SUITE", 24.0)
    );
}

๊ฐ์‹ค ๋ฆฌ์ŠคํŠธ๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๋Š” ๋ฉ”์†Œ๋“œ์ด๋‹ค.

  1. showMain() ๋ฉ”์†Œ๋“œ
// ์ฒซ ํ™”๋ฉด์—์„œ ๋ฉ”๋‰ด๋“ค์„ ์ถœ๋ ฅํ•˜๋Š” ๋ฉ”์†Œ๋“œ
public void showMain() {
    Scanner sc = new Scanner(System.in);
    while (true) {
        System.out.println("\n-----๋ฉ”์ธ ๋ฉ”๋‰ด-----");
        System.out.println("1. ๊ณ ๊ฐ");
        System.out.println("2. ํ˜ธํ…”");
        System.out.println("3. ์ข…๋ฃŒ");

        System.out.print("๋ฉ”๋‰ด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");
        String menu = sc.nextLine();

        if (menu.equals("๊ณ ๊ฐ") || menu.equals("1")) {
            showCustomerMenu();
        } else if (menu.equals("ํ˜ธํ…”") || menu.equals("2")) {
            showHotelMenu();
        } else if (menu.equals("์ข…๋ฃŒ") || menu.equals("3")) {
            System.out.println("โ˜… ๋ถˆ์ข€๊บผ์กฐ ํ˜ธํ…” ์˜ˆ์•ฝ ํ”„๋กœ๊ทธ๋žจ์„ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค โ˜…");
            break;
        } else {
            System.out.println("์ž˜๋ชป๋œ ๋ฉ”๋‰ด์ž…๋‹ˆ๋‹ค.");
        }
    } // while()
} // showMain()

๋ฉ”์ธ ๋ฉ”๋‰ด๋ฅผ ์ถœ๋ ฅํ•ด์ค€๋‹ค. 1๋ฒˆ์˜ ๊ฒฝ์šฐ showCustomerMenu() ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ, 2๋ฒˆ์˜ ๊ฒฝ์šฐ showHotelMenu() ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ, 3๋ฒˆ์˜ ๊ฒฝ์šฐ ๋ฐ˜๋ณต๋ฌธ์„ ์ข…๋ฃŒํ•œ๋‹ค. ์ž˜๋ชป ์ž…๋ ฅํ–ˆ์„ ๊ฒฝ์šฐ ์ž˜๋ชป ์ž…๋ ฅํ–ˆ๋‹ค๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ๋„์šด ํ›„ ๋‹ค์‹œ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.

  1. showCustomerMenu() ๋ฉ”์†Œ๋“œ
// ๊ณ ๊ฐ ์„ธ๋ถ€ ๋ฉ”๋‰ด๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ฉ”์†Œ๋“œ
public void showCustomerMenu() {
    Scanner sc = new Scanner(System.in);
    System.out.println("\n--------๊ณ ๊ฐ ํŽ˜์ด์ง€--------");
    System.out.println("1. ์˜ˆ์•ฝํ•˜๊ธฐ");
    System.out.println("2. ์˜ˆ์•ฝ ๋‚ด์—ญ ํ™•์ธํ•˜๊ธฐ & ์‚ญ์ œํ•˜๊ธฐ");
    System.out.println("3. ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ€๊ธฐ");
    System.out.print("๋ฉ”๋‰ด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");
    String detailMenu = sc.nextLine();
    if (detailMenu.equals("1") || detailMenu.equals("์˜ˆ์•ฝํ•˜๊ธฐ")) {
        // ๊ฐ์‹ค ๋ฆฌ์ŠคํŠธ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ
        String date1 = showRoomList();
        Room room1 = inputRoom();
        Customer customer1 = inputCustomer(room1);
        reservationComplete(room1, customer1, date1);
    } else if (detailMenu.equals("2") || "์˜ˆ์•ฝ ๋‚ด์—ญ ํ™•์ธํ•˜๊ธฐ & ์‚ญ์ œํ•˜๊ธฐ".contains(detailMenu)) {
        // ์˜ˆ์•ฝ ๋‚ด์—ญ ํ™•์ธํ•˜๊ธฐ
        reservationConfirm();
    } else if ((detailMenu.equals("3") || "๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ€๊ธฐ".contains(detailMenu))) {
    } else {
        System.out.println("์ž˜๋ชป๋œ ๋ฉ”๋‰ด์ž…๋‹ˆ๋‹ค.");
    }
} // showCustomerMenu()

๊ณ ๊ฐ ์„ธ๋ถ€ ๋ฉ”๋‰ด๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. 1๋ฒˆ์˜ ๊ฒฝ์šฐ showRoomList(), inputRoom(), inputCustomer(), reservationComplete() ๋ฉ”์†Œ๋“œ๋ฅผ ์ฐจ๋ก€๋กœ ํ˜ธ์ถœํ•œ๋‹ค. 2๋ฒˆ์˜ ๊ฒฝ์šฐ reservationConfirm() ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๊ณ  3๋ฒˆ์˜ ๊ฒฝ์šฐ ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ„๋‹ค.

  1. showRoomList() ๋ฉ”์†Œ๋“œ
// ๊ฐ์‹ค ๋ฆฌ์ŠคํŠธ ์ถœ๋ ฅํ•˜๋Š” ๋ฉ”์†Œ๋“œ - ์˜ˆ์•ฝํ•˜๊ณ  ์‹ถ์€ ๋‚ ์งœ๋ฅผ ์ž…๋ ฅ ๋ฐ›๊ธฐ & ์˜ˆ์•ฝ ๋‚ ์งœ๋ฅผ ๋ฆฌํ„ด
public String showRoomList() {
    System.out.println("\n------ ๊ฐ์‹ค ๋ชฉ๋ก ------");
    String resDate = null;
    LocalDate today = LocalDate.now(); 

    System.out.println("์˜ค๋Š˜์€ " + LocalDate.now() + " ์ž…๋‹ˆ๋‹ค.");        // ์˜ค๋Š˜ ๋‚ ์งœ ์ถœ๋ ฅ(iso 8601์— ๋”ฐ๋ผ ํ‘œํ˜„๋œ ๋‚ ์งœ)
    Scanner scan = new Scanner(System.in);                              // ๊ณ ๊ฐ์œผ๋กœ๋ถ€ํ„ฐ ์›ํ•˜๋Š” ๋‚ ์งœ ์ž…๋ ฅ๋ฐ›๊ธฐ
    String pattern = "\\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])"; // yyyy๋…„ MM์›” dd์ผ ํƒ€์ž…์œผ๋กœ ์ž…๋ ฅ๋ฐ›๊ธฐ

    while (true) {
        System.out.println("yyyy-MM-dd ํ˜•ํƒœ๋กœ ์›ํ•˜์‹œ๋Š” ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”. ์˜ˆ: 2023-06-05 ");
        resDate = scan.nextLine();
        if (Pattern.matches(pattern, resDate)) { //๋‚ ์งœ ํ˜•์‹ ์ฒดํฌ
            LocalDate reservationDate = LocalDate.parse(resDate);
            int compare = reservationDate.compareTo(today);
            if (compare < 0) {
                System.out.println("์˜ค๋Š˜ ์ด์ „์˜ ๋‚ ์€ ์ž…๋ ฅํ•˜์‹ค ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.");
                continue;
            }
            System.out.printf("%-13s | %s\n", "๋ฐฉ ์ด๋ฆ„", "๊ฐ€๊ฒฉ(๋งŒ์›)");
            for (Room room : roomList) {
                if (!room.getDateList().contains(resDate)) {
                    System.out.printf("%-15s | %.1f\n", room.getRoomSize(), room.getRoomCharge());
                }
            }
            break;
        }
        System.out.println("๋‚ ์งœ ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.");
    }
    return resDate;
}

์ž…๋ ฅ๋ฐ›์€ ์˜ˆ์•ฝ ๊ฐ€๋Šฅํ•œ ๊ฐ์‹ค์˜ ๋ฆฌ์ŠคํŠธ๋ฅผ ์ถœ๋ ฅํ•ด์ค€๋‹ค. ์˜ค๋Š˜ ๋‚ ์งœ๋ฅผ ์ถœ๋ ฅํ•ด์ฃผ๊ณ , ๊ณ ๊ฐ์—๊ฒŒ ๋‚ ์งœ๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. ๋งŒ์•ฝ ๋‚ ์งœ๋ฅผ ์ž˜๋ชป ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ๋‚˜ ์˜ค๋Š˜ ์ด์ „์˜ ๋‚ ์„ ์ž…๋ ฅ๋ฐ›์€ ๊ฒฝ์šฐ ๋‚ ์งœ๋ฅผ ๋‹ค์‹œ ์ž…๋ ฅ๋ฐ›๊ณ , ์ œ๋Œ€๋กœ ๋œ ๋‚ ์งœ๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๊ฒฝ์šฐ ํ•ด๋‹น ๋‚ ์งœ์— ๊ฐ€๋Šฅํ•œ ๊ฐ์‹ค๋งŒ ์ถœ๋ ฅํ•ด์ค€๋‹ค.

  1. inputRoom() ๋ฉ”์†Œ๋“œ
// ๊ฐ์‹ค ์ž…๋ ฅ๋ฐ›๋Š” ๋ฉ”์†Œ๋“œ - ์ž…๋ ฅ๋ฐ›์•„์„œ ๋‹ค์Œ ๋ฉ”์†Œ๋“œ์ธ ๊ณ ๊ฐ ์ •๋ณด๋ฅผ ์ž…๋ ฅ ๋ฐ›์„ ๋•Œ Room ํƒ€์ž…์˜ ํ•„๋“œ๋ฅผ ๋„˜๊ฒจ์คŒ
public Room inputRoom() {
    System.out.println("\n------ ๊ฐ์‹ค ์ •๋ณด ์ž…๋ ฅ ------");
    Scanner scanner = new Scanner(System.in);
    System.out.println("์˜ˆ์•ฝํ•˜์‹ค ๊ฐ์‹ค์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š” ex)FAMILY_SUITE");
    String roomType = scanner.nextLine();                            // ๊ณ ๊ฐ์œผ๋กœ๋ถ€ํ„ฐ ๊ฐ์‹ค์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค
    boolean a = false;
    for (Room room : roomList) {
        a = room.getRoomSize().equals(roomType);                     // ์˜ฌ๋ฐ”๋ฅธ ๊ฐ์‹ค ์ด๋ฆ„์„ ์ž…๋ ฅํ–ˆ๋‹ค๋ฉด
        if (a) {
            return room;                                             // ํ•ด๋‹น ๊ฐ์‹ค์„ ๋ฆฌํ„ดํ•œ๋‹ค
        }
    }
    if (a == false) {
        System.out.println("์ž˜๋ชป ์ž…๋ ฅํ•˜์…จ์Šต๋‹ˆ๋‹ค");                     // ์ž˜๋ชป ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•˜๊ณ 
        return inputRoom();                                          // ๋ฉ”์†Œ๋“œ๋ฅผ ๋‹ค์‹œ ํ˜ธ์ถœํ•œ๋‹ค
    }
    return null;
} // inputRoom()

๊ณ ๊ฐ์œผ๋กœ๋ถ€ํ„ฐ ์›ํ•˜๋Š” ๊ฐ์‹ค์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. ๊ฐ์‹ค์˜ ํƒ€์ž…์„ ์ž…๋ ฅ๋ฐ›์•„ ์กด์žฌํ•˜๋ฉด ํ•ด๋‹น Room ํƒ€์ž…์˜ ๊ฐ์‹ค์„ ๋ฆฌํ„ดํ•˜๊ณ , ์ž˜๋ชป ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ ๋ฉ”์†Œ๋“œ๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค.

  1. inputCustomer() ๋ฉ”์†Œ๋“œ
// ๊ณ ๊ฐ ์ •๋ณด๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š” ๋ฉ”์†Œ๋“œ - ๊ณ ๊ฐ ์ •๋ณด๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„์„œ ์žˆ์œผ๋ฉด ๊ทธ๋ƒฅ ์ง„ํ–‰ํ•˜๊ณ , ์—†์œผ๋ฉด ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€ํ•˜๊ธฐ. ๊ทธ ๋‹ค์Œ์— ์†Œ์ง€๊ธˆ ํŒ๋‹จํ•˜๊ธฐ
public Customer inputCustomer(Room room) {
    Scanner sc = new Scanner(System.in);
    System.out.println("\n------ ๊ณ ๊ฐ ์ •๋ณด ์ž…๋ ฅ ------");

    System.out.print("์„ฑํ•จ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");
    String name = sc.nextLine();
    String phone = InputPhoneCheck();        // ์ „ํ™”๋ฒˆํ˜ธ ์ž…๋ ฅ๋ฐ›๊ธฐ
    System.out.print("์†Œ์ง€๊ธˆ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š” โ€ป1์€ 1๋งŒ์›์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. :  ");
    Double cash = sc.nextDouble();

    Customer customer = new Customer(name, phone, cash);    // ๊ณ ๊ฐ ์ƒ์„ฑ์ž๋ฅผ ๋งŒ๋“ ๋‹ค
    boolean found = false;                                  // ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์— ์ž…๋ ฅ๋ฐ›์€ ๊ณ ๊ฐ์˜ ์กด์žฌ ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•˜๋Š” boolean ํƒ€์ž… ํ•„๋“œ ์„ ์–ธ
    for (Customer c : customerList) {
        if (c.getName().equals(customer.getName()) && c.getPhone().equals(customer.getPhone())) {
            found = true;
            c.setCash(customer.getCash());
            break;
        }
    }
    if (!found) {                       // ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์— ๊ณ ๊ฐ์ด ์—†๋‹ค๋ฉด
        customerList.add(customer);     // ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์— ๊ณ ๊ฐ์„ ์ถ”๊ฐ€ํ•œ๋‹ค
    }

    if (customer.getCash() >= room.getRoomCharge()) {                     // ๊ณ ๊ฐ์˜ ์†Œ์ง€๊ธˆ์ด ๊ฐ์‹ค์˜ ๊ฐ€๊ฒฉ๋ณด๋‹ค ๋งŽ๋‹ค๋ฉด
        customer.setCash(customer.getCash() - room.getRoomCharge());      // ์†Œ์ง€๊ธˆ์—์„œ ๊ฐ์‹ค ๊ฐ€๊ฒฉ์„ ์ฐจ๊ฐํ•œ ํ›„
        System.out.println("์˜ˆ์•ฝ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.");                          // ์˜ˆ์•ฝ ๊ฐ€๋Šฅํ•จ์„ ์•Œ๋ ค์ค€๋‹ค
    } else {
        System.out.println("์†Œ์ง€๊ธˆ์ด ๋ถ€์กฑํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ์•ฝ์ด ๋ถˆ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.");       // ์†Œ์ง€๊ธˆ์ด ๊ฐ์‹ค ๊ฐ€๊ฒฉ๋ณด๋‹ค ์ ๋‹ค๋ฉด ์˜ˆ์•ฝ ๋ถˆ๊ฐ€๋ฅผ ์•Œ๋ ค์ฃผ๊ณ 
        customer = null;                                                  // ๊ณ ๊ฐ์„ null๋กœ ๋ฆฌํ„ดํ•œ๋‹ค
    }
    return customer;
} // inputCustomer()

๊ณ ๊ฐ์˜ ์ •๋ณด๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. ์ด๋ฆ„๊ณผ ์ „ํ™”๋ฒˆํ˜ธ, ์†Œ์ง€๊ธˆ์„ ์ž…๋ ฅ๋ฐ›๊ณ  Customer ํƒ€์ž…์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ๋งŒ๋“ ๋‹ค. ๋งŒ์•ฝ ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์— ํ•ด๋‹น ๊ณ ๊ฐ์ด ์กด์žฌํ•  ๊ฒฝ์šฐ, ์†Œ์ง€๊ธˆ๋งŒ ๋‹ค์‹œ ์„ค์ •ํ•ด์ฃผ๊ณ  ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์— ๊ณ ๊ฐ์ด ์—†๋‹ค๋ฉด ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์— ์ƒˆ ๊ณ ๊ฐ์„ ์ถ”๊ฐ€ํ•œ๋‹ค. ๊ณ ๊ฐ์˜ ์†Œ์ง€๊ธˆ์ด ์„ ํƒํ•œ ๊ฐ์‹ค์˜ ๊ฐ€๊ฒฉ๋ณด๋‹ค ๋งŽ๋‹ค๋ฉด ์†Œ์ง€๊ธˆ์—์„œ ๊ฐ์‹ค์˜ ๊ฐ€๊ฒฉ์„ ์ฐจ๊ฐํ•˜๊ณ  ์˜ˆ์•ฝ ๊ฐ€๋Šฅํ•จ์„ ์•Œ๋ ค์ค€๋‹ค. ์†Œ์ง€๊ธˆ์ด ๊ฐ์ผ ๊ฐ€๊ฒฉ๋ณด๋‹ค ์ ๋‹ค๋ฉด ์˜ˆ์•ฝ ๋ถˆ๊ฐ€๋ฅผ ์•Œ๋ ค์ฃผ๊ณ  ๊ณ ๊ฐ์„ null๋กœ ์„ค์ •ํ•œ๋‹ค.

  1. reservationComplete() - ๋ฉ”์†Œ๋“œ
// ์˜ˆ์•ฝ ์™„๋ฃŒ ํ™”๋ฉด - ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ๋ฐ˜ํ™˜ (uuid), ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ ์•ˆ์— Reservation (๊ฐ์‹ค๊ณผ ๊ณ ๊ฐ์ด๋ฆ„๊ณผ ๊ณ ๊ฐ์ „ํ™”๋ฒˆํ˜ธ, ์˜ˆ์•ฝ๋‚ ์งœ, ์˜ˆ์•ฝ๋ฒˆํ˜ธ) ์ €์žฅํ•˜๊ธฐ
public void reservationComplete(Room room, Customer customer, String date) {
    System.out.println();
    System.out.println("------ ์˜ˆ์•ฝ ์™„๋ฃŒ ํŽ˜์ด์ง€ ------");
    Reservation reservation = null;
    if (customer != null) {                                                                  // ๊ณ ๊ฐ์ด null์ด ์•„๋‹ˆ๋ผ๋ฉด (์†Œ์ง€๊ธˆ์ด ๊ฐ์‹ค ๊ฐ€๊ฒฉ๋ณด๋‹ค ๋งŽ์€ ๊ณ ๊ฐ์˜ ๊ฒฝ์šฐ)
        reservation = new Reservation(room, customer.getName(), customer.getPhone(), date);  // Reservation ๋ฅผ ๋งŒ๋“ค์–ด์ค€๋‹ค
        reservationList.add(reservation);                                                    // ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ์— ์˜ˆ์•ฝ์„ ์ถ”๊ฐ€ํ•ด์ฃผ๊ณ 
        room.setDateList(date);                                                              // ํ•ด๋‹น ๊ฐ์‹ค์— ์˜ˆ์•ฝํ•œ ๋‚ ์งœ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค
        System.out.println("์˜ˆ์•ฝ์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
        System.out.println("๊ณ ๊ฐ๋‹˜์˜ ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋Š” " + reservation.getId() + "์ž…๋‹ˆ๋‹ค.");         // ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ๊ณ ๊ฐ์—๊ฒŒ ์ถœ๋ ฅํ•œ๋‹ค
    } else {
        System.out.println("์˜ˆ์•ฝ์ด ๋ถˆ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ๋ฉ”์ธ ํ™”๋ฉด์œผ๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");
    }
} // reservationComplete()

์˜ˆ์•ฝ ์™„๋ฃŒ๋จ์„ ์•Œ๋ ค์ฃผ๋ฉฐ ๊ณ ๊ฐ์—๊ฒŒ ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ๋ฐ˜ํ™˜ํ•ด์ฃผ๋Š” ๋ฉ”์†Œ๋“œ์ด๋‹ค. ๋งŒ์•ฝ ๊ณ ๊ฐ์ด null์ด ์•„๋‹Œ ๊ฒฝ์šฐ, ์ฆ‰ ๊ณ ๊ฐ์˜ ์†Œ์ง€๊ธˆ์ด ๊ฐ์‹ค์˜ ๊ฐ€๊ฒฉ๋ณด๋‹ค ๋งŽ์•„ ์˜ˆ์•ฝ์ด ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ์— Reservation ์ธ์Šคํ„ด์Šค๋ฅผ ๋งŒ๋“ ๋‹ค. ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ์— ๋งŒ๋“  ์˜ˆ์•ฝ์„ ์ถ”๊ฐ€ํ•˜๊ณ , ๊ฐ์‹ค์— ์˜ˆ์•ฝ ๋‚ ์งœ(์ˆ™๋ฐ•์ผ)์„ ์ถ”๊ฐ€ํ•œ ํ›„, ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ๊ณ ๊ฐ์—๊ฒŒ ์ถœ๋ ฅํ•ด์ค€๋‹ค.

  1. reservationConfirm() ๋ฉ”์†Œ๋“œ
// ์˜ˆ์•ฝ ํ™•์ธ - ์ด๋ฆ„๊ณผ ์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ  ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์—์„œ ํŒ๋ณ„ํ•˜๊ธฐ, ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์— ์žˆ์œผ๋ฉด ์˜ˆ์•ฝ ๋ชฉ๋ก์—์„œ ์ถœ๋ ฅ
public void reservationConfirm() {
    Scanner sc = new Scanner(System.in);
    System.out.print("์„ฑํ•จ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");          // ๊ณ ๊ฐ์˜ ์„ฑํ•จ๊ณผ ์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ์šฐ์„  ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
    String name = sc.nextLine();
    String phoneNumber = InputPhoneCheck();
    boolean custo = false;                            // ๊ณ ๊ฐ์ด ๋ฆฌ์ŠคํŠธ์— ์กด์žฌํ•  ์ง€ ํŒ๋‹จํ•˜๋Š” boolean ํƒ€์ž…์˜ ํ•„๋“œ ์„ ์–ธ
    
    for (Customer customer : customerList) {          // ๊ณ ๊ฐ ๋ฆฌ์ŠคํŠธ์— ํ•ด๋‹น ๊ณ ๊ฐ์ด ์กด์žฌํ•˜๋Š”์ง€ ํŒ๋‹จ
        if (customer.getName().equals(name) && customer.getPhone().equals(phoneNumber)) {
            custo = true;
        }
    }
    if (custo) {           // ๊ณ ๊ฐ์ด ์กด์žฌํ•œ๋‹ค๋ฉด
        Integer count = 0; // ํ•ด๋‹น ๊ณ ๊ฐ์˜ ์˜ˆ์•ฝ ๊ฑด์ˆ˜ count
        for (Reservation reservation : reservationList) {
            if (reservation.getCustomerName().equals(name) && reservation.getPhoneNumber().equals(phoneNumber)) {
                count += 1;
            } // if๋ฌธ ์ข…๋ฃŒ
        } // for๋ฌธ ์ข…๋ฃŒ

        if (count > 0) { // ์˜ˆ์•ฝ ๊ฑด์ˆ˜๊ฐ€ ํ•˜๋‚˜ ์ด์ƒ์ด๋ผ๋ฉด
            System.out.println("\n" +name + "๋‹˜์˜ ์˜ˆ์•ฝ ๋‚ด์—ญ (์ด "+count+"๊ฑด)์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.");
            for (Reservation reservation : reservationList) {     // ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ์—์„œ ์˜ˆ์•ฝ ๋‚ด์—ญ ์ถœ๋ ฅํ•˜๊ธฐ
                if (reservation.getCustomerName().equals(name) && reservation.getPhoneNumber().equals(phoneNumber)) {
                    System.out.printf("%-4s | %-10s | %s | %s\n", reservation.getCustomerName(), reservation.getRoom().getRoomSize(), reservation.getReservationDate(), reservation.getId());
                } // if๋ฌธ ์ข…๋ฃŒ
            } // for๋ฌธ ์ข…๋ฃŒ
            deleteReservation(); // ์˜ˆ์•ฝ ์‚ญ์ œ ์—ฌ๋ถ€๋ฅผ ๋ฌผ์–ด๋ณด๋Š” ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ
        } else { // ์˜ˆ์•ฝ ๊ฑด์ˆ˜๊ฐ€ ์—†๋‹ค๋ฉด
            System.out.println("\n๊ณ ๊ฐ๋‹˜์˜ ์˜ˆ์•ฝ ๋‚ด์—ญ์ด ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.");
            System.out.println("3์ดˆ ํ›„ ๊ณ ๊ฐ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");
            try {
                Thread.sleep(3000);
                showCustomerMenu();
            } catch (InterruptedException e) {
                System.out.println(e.getMessage());
            }
        }
    } else {   // ๊ณ ๊ฐ์ด ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด
        System.out.println("\n๊ณ ๊ฐ๋‹˜์˜ ์ •๋ณด๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.");
        System.out.println("๊ณ ๊ฐ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค");
        showCustomerMenu();
    }
}

๊ณ ๊ฐ์˜ ์˜ˆ์•ฝ ๋‚ด์—ญ์„ ์กฐํšŒํ•ด์ค€๋‹ค. ๊ณ ๊ฐ์˜ ์ด๋ฆ„๊ณผ ์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ , ๊ณ ๊ฐ๋ฆฌ์ŠคํŠธ์— ์กด์žฌํ•˜๋ฉด ์˜ˆ์•ฝ ๊ฑด์ˆ˜๋ฅผ count ํ•œ๋‹ค. countํ•œ ๊ณ ๊ฐ์˜ ์˜ˆ์•ฝ ๊ฑด์ˆ˜๊ฐ€ ํ•˜๋‚˜ ์ด์ƒ์ด๋ผ๋ฉด ์˜ˆ์•ฝ ๋‚ด์—ญ์„ ์ถœ๋ ฅํ•ด์ฃผ๊ณ , ์˜ˆ์•ฝ ๊ฑด์ˆ˜๊ฐ€ ์—†๋‹ค๋ฉด ์˜ˆ์•ฝ ๋‚ด์—ญ์ด ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค๊ณ  ์•Œ๋ ค์ค€ ํ›„ ๊ณ ๊ฐ ๋ฉ”๋‰ด๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ๊ณ ๊ฐ์ด ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด ๊ณ ๊ฐ ์ •๋ณด๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋‹ค๊ณ  ์•Œ๋ ค์ค€ ํ›„, ๊ณ ๊ฐ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ„๋‹ค.

  1. deleteReservation() ๋ฉ”์†Œ๋“œ
// ์˜ˆ์•ฝ์„ ์‚ญ์ œํ•˜๋Š” ๋ฉ”์†Œ๋“œ
public void deleteReservation() {
    Scanner sc = new Scanner(System.in);
    System.out.println("\n์˜ˆ์•ฝ ๋‚ด์—ญ์„ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?(์˜ˆ/์•„๋‹ˆ์˜ค): ");
    String yesNo = sc.nextLine();
    if (yesNo.equals("์˜ˆ")) {
        System.out.print("์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");
        String reservationNum = sc.nextLine();                     // ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค
        Boolean yesOrNo = false;                                   // ์ž…๋ ฅ๋ฐ›์€ ์˜ˆ์•ฝ ๋ฒˆํ˜ธ์— ํ•ด๋‹นํ•˜๋Š” ์˜ˆ์•ฝ์ด ์žˆ๋Š”์ง€ ํŒ๋ณ„ํ•˜๋Š” boolean ํƒ€์ž…์˜ ํ•„๋“œ ์„ ์–ธ
        Reservation r = null;                                      
        for (Reservation reservation : reservationList) {
            if (reservation.getId().equals(reservationNum)) {      // ์˜ˆ์•ฝ ๋ฒˆํ˜ธ์— ํ•ด๋‹นํ•˜๋Š” ์˜ˆ์•ฝ์ด ์กด์žฌํ•œ๋‹ค๋ฉด
                r = reservation;                                   // Reservation ํƒ€์ž…์˜ ํ•„๋“œ ์•ˆ์— ํ•ด๋‹น ์˜ˆ์•ฝ์„ ๋„ฃ์–ด์ค€๋‹ค
                yesOrNo = true;                                    // yesOrNo๋ฅผ true๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค
            } // if๋ฌธ ์ข…๋ฃŒ
        } // for๋ฌธ ์ข…๋ฃŒ

        if (!yesOrNo) {                                              // ์˜ˆ์•ฝ ๋ฒˆํ˜ธ์— ํ•ด๋‹นํ•˜๋Š” ์˜ˆ์•ฝ์ด ์—†๋Š” ๊ฒฝ์šฐ
            System.out.println("์ž˜๋ชป๋œ ์˜ˆ์•ฝ ๋ฒˆํ˜ธ์ž…๋‹ˆ๋‹ค.");
        } else {                                                     // ์˜ˆ์•ฝ์ด ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ
            reservationList.remove(r);                               // ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ์—์„œ ํ•ด๋‹น ์˜ˆ์•ฝ ์‚ญ์ œ
            Room removeroom = r.getRoom();                           // ๊ฐ์‹ค ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์™€์„œ
            removeroom.getDateList().remove(r.getReservationDate()); // ๊ฐ์‹ค์— ํ•ด๋‹น ๋‚ ์งœ๋„ ์‚ญ์ œํ•˜๊ธฐ
            System.out.println("์˜ˆ์•ฝ์ด ์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
        }

    } else if (yesNo.equals("์•„๋‹ˆ์˜ค")) {                              // ์˜ˆ์•ฝ ๋‚ด์—ญ ์‚ญ์ œ๋ฅผ ์›ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ
        System.out.println("๊ณ ๊ฐ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");                 // ๋‹ค์‹œ ๊ณ ๊ฐ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ
        showCustomerMenu();
    } else {
        System.out.println("์ž˜๋ชป ์ž…๋ ฅํ•˜์…จ์Šต๋‹ˆ๋‹ค. ๊ณ ๊ฐ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");
        showCustomerMenu();
    }
} // deleteReservation()

์˜ˆ์•ฝ์„ ์‚ญ์ œํ•˜๋Š” ๋ฉ”์†Œ๋“œ์ด๋‹ค. ์‚ญ์ œ ์—ฌ๋ถ€๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ  ์‚ญ์ œ๋ฅผ ์›ํ•˜๋Š” ๊ฒฝ์šฐ, ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. ์ž…๋ ฅ๋ฐ›์€ ์˜ˆ์•ฝ ๋ฒˆํ˜ธ์— ํ•ด๋‹นํ•˜๋Š” ์˜ˆ์•ฝ์ด ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ, ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ์—์„œ ํ•ด๋‹น ์˜ˆ์•ฝ์„ ์‚ญ์ œํ•˜๊ณ , ํ•ด๋‹น ๊ฐ์‹ค์˜ ๋‚ ์งœ ๋ฆฌ์ŠคํŠธ ์•ˆ์—์„œ ํ•ด๋‹น ๋‚ ์งœ๋„ ํ•จ๊ป˜ ์ง€์›Œ์ค€๋‹ค. ์‚ญ์ œ๋ฅผ ์›ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ๋‹ค์‹œ ๊ณ ๊ฐ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ„๋‹ค.

  1. showHotelMenu() ๋ฉ”์†Œ๋“œ
// ํ˜ธํ…”์˜ ๋ฉ”๋‰ด๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ฉ”์†Œ๋“œ
public void showHotelMenu() {
    System.out.println();
    System.out.println("------ ํ˜ธํ…” ํŽ˜์ด์ง€ ------");
    System.out.println("๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");
    Scanner sc = new Scanner(System.in);
    String inputPassword = sc.nextLine();

    if (inputPassword.equals(password)) {
        System.out.println("1. ํ˜ธํ…” ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ");
        System.out.println("2. ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ •");
        System.out.print("๋ฉ”๋‰ด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");
        String inputMenu = sc.nextLine();

        if (inputMenu.equals("1") || "ํ˜ธํ…” ์˜ˆ์•ฝ ๋ฆฌ์ŠคํŠธ".contains(inputMenu)) {
            showAllReservation();
        } else if (inputMenu.equals("2") || "๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ •".contains(inputMenu)) {
            setPassword();
        }
    } else {
        System.out.println("๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ํ‹€๋ ธ์Šต๋‹ˆ๋‹ค.");
        System.out.println("3์ดˆ ํ›„ ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            System.out.println(e.getMessage());
        }
    }
} // showHotelMenu()

๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ , ์ผ์น˜ํ•˜๋Š” ๊ฒฝ์šฐ ํ˜ธํ…” ๋ฉ”๋‰ด๋ฅผ ์ถœ๋ ฅํ•˜๊ณ  ์ผ์น˜ํ•˜์ง€ ์•Š์œผ๋ฉด ๋‹ค์‹œ ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ„๋‹ค. ํ˜ธํ…” ๋ฉ”๋‰ด์—์„œ 1๋ฒˆ์„ ๋ˆ„๋ฅด๋ฉด showAllReservation() ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๊ณ , 2๋ฒˆ์„ ๋ˆ„๋ฅด๋ฉด setPassword() ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค.

  1. showAllReservation() ๋ฉ”์†Œ๋“œ
// ํ˜ธํ…”์—์„œ ๋ชจ๋“  ์˜ˆ์•ฝ ๋ชฉ๋ก ์กฐํšŒ ๊ธฐ๋Šฅ
public void showAllReservation() {
    System.out.println();
    System.out.println("------ ์˜ˆ์•ฝ ๋‚ด์—ญ ๊ด€๋ฆฌ์ž ํŽ˜์ด์ง€ ------");
    System.out.println("๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");
    Scanner sc = new Scanner(System.in);
    while (true) {
        String inputPassword = sc.nextLine();                      // ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„
        if (inputPassword.equals(password)) {                      // ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ์ผ์น˜ํ•˜๋Š” ๊ฒฝ์šฐ
            if (reservationList.isEmpty()) {                       // ์˜ˆ์•ฝ ๋‚ด์—ญ์ด ๋น„์–ด์žˆ๋Š” ๊ฒฝ์šฐ
                System.out.println("์˜ˆ์•ฝ ๋‚ด์—ญ์ด ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.");
            } else {                                               // ์˜ˆ์•ฝ ๋‚ด์—ญ์ด ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ
                for (Reservation r : reservationList) {
                    System.out.printf("%s | %-4.1f | %-5s | %12s | %10s | %s\n", r.getRoom().getRoomSize(), r.getRoom().getRoomCharge(), r.getCustomerName(), r.getPhoneNumber(), r.getReservationDate(), r.getId());
                }
            }
            break;
        } else {
            System.out.println("๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");
        }
    } // while()
    System.out.println("\n3์ดˆ ํ›„ ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");
    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        System.out.println(e.getMessage());
    }
} // showAllReservation()

ํ˜ธํ…”์—์„œ ๋ชจ๋“  ์˜ˆ์•ฝ ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค. ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ์ผ์น˜ํ•˜๋ฉด, ์˜ˆ์•ฝ ๋‚ด์—ญ์„ ์กฐํšŒํ•˜๋Š”๋ฐ ์˜ˆ์•ฝ ๋‚ด์—ญ์ด ๋น„์–ด์žˆ์œผ๋ฉด ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค๊ณ  ์•Œ๋ ค์ฃผ๊ณ , ์˜ˆ์•ฝ ๋‚ด์—ญ์ด ์žˆ๋‹ค๋ฉด ์ถœ๋ ฅํ•ด์ค€๋‹ค. ๊ทธ ๋‹ค์Œ 3์ดˆ ํ›„์— ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ„๋‹ค.

  1. setPassword() ๋ฉ”์†Œ๋“œ
// ํ˜ธํ…”์˜ ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ˆ˜์ •ํ•˜๋Š” ๋ฉ”์†Œ๋“œ
public void setPassword() {
    System.out.println("\n------ ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ • ํŽ˜์ด์ง€ ------");
    System.out.print("๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ˆ˜์ •ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? (์˜ˆ/์•„๋‹ˆ์˜ค): ");
    Scanner sc = new Scanner(System.in);

    String yesno = sc.nextLine();

    if (yesno.equals("์˜ˆ")) {
        System.out.print("๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋‹ค์‹œ ํ•œ ๋ฒˆ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");
        String newPW = sc.nextLine();

        if (newPW.equals(password)) {
            System.out.print("์ˆ˜์ •ํ•  ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”: ");
            String newsetPW = sc.nextLine();
            this.password = newsetPW;
        } else {
            System.out.println("๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ํ‹€๋ ธ์Šต๋‹ˆ๋‹ค.");
        }

        System.out.println("๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
    } else {
        System.out.println("3์ดˆ ํ›„ ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            System.out.println(e.getMessage());
        }
    }
} // setPassword()

ํ˜ธํ…” ๊ด€๋ฆฌ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ˆ˜์ •ํ•œ๋‹ค. ๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ • ์—ฌ๋ถ€๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ , ์ˆ˜์ •ํ•˜๊ฒ ๋‹ค๊ณ  ์ž…๋ ฅ๋ฐ›์œผ๋ฉด ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ํ•œ ๋ฒˆ ๋” ์ž…๋ ฅ๋ฐ›๊ณ , ์ˆ˜์ •ํ•  ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. ์ˆ˜์ •ํ•  ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ณ€๊ฒฝํ•œ ํ›„ ๋ฉ”์ธ ๋ฉ”๋‰ด๋กœ ๋Œ์•„๊ฐ„๋‹ค.

  1. InputPhoneCheck() ๋ฉ”์†Œ๋“œ
// ์ „ํ™”๋ฒˆํ˜ธ ์ •๊ทœ์‹ ํŒ๋ณ„ํ•˜๋Š” ๋ฉ”์†Œ๋“œ
private String InputPhoneCheck() { // ์ „ํ™”๋ฒˆํ˜ธ ์ •๊ทœํ‘œํ˜„์‹
    Scanner scan = new Scanner(System.in);
    String pattern = "^01(?:0|1|[6-9])-(?:\\d{3}|\\d{4})-\\d{4}$"; // ์ˆซ์ž๋งŒ ๋“ฑ์žฅํ•˜๋Š”์ง€
    while (true) {
        System.out.print("์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š” ex)000-0000-0000 : ");
        String inputPhone = scan.nextLine();
        if (Pattern.matches(pattern, inputPhone))
            return inputPhone;
        System.out.println("์˜ฌ๋ฐ”๋ฅธ ์ „ํ™”๋ฒˆํ˜ธ ํ˜•์‹์ด ์•„๋‹™๋‹ˆ๋‹ค. ๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”");
    }
} // InputPhoneCheck()

์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›์„ ๋•Œ, ์ •๊ทœ ํ‘œํ˜„์‹์— ๋งž๋Š”์ง€ ํŒ๋‹จํ•œ๋‹ค. ์ „ํ™”๋ฒˆํ˜ธ ํ˜•์‹์— ์ผ์น˜ํ•˜๋ฉด ์ž…๋ ฅ๋ฐ›์€ ์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ๋ฆฌํ„ดํ•˜๊ณ , ์ผ์น˜ํ•˜์ง€ ์•Š์œผ๋ฉด ๋‹ค์‹œ ์ž…๋ ฅ๋ฐ›๋„๋ก ํ•œ๋‹ค.

  1. Main.java
public class Main {

    public static void main(String[] args) {
        Hotel hotel = new Hotel();
        hotel.init();              // ๊ฐ์‹ค ๋ฆฌ์ŠคํŠธ ์ƒ์„ฑํ•˜๊ธฐ
        System.out.println("โ˜† ๋ถˆ์ข€๊บผ์กฐ ํ˜ธํ…”์— ์˜ค์‹  ๊ฒƒ์„ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค โ˜†");
        hotel.showMain();          // ๋ฉ”์ธ ๋ฉ”๋‰ด ์ถœ๋ ฅํ•˜๊ธฐ
    }
}

Hotel ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. init()๋ฉ”์†Œ๋“œ๋กœ ๊ฐ์‹ค ๋ฆฌ์ŠคํŠธ๋ฅผ ์ดˆ๊ธฐํ™” ํ•œ ๋‹ค ๋ฉ”์ธ ๋ฉ”๋‰ด ๋ฉ”์†Œ๋“œ์ธ showMain()์„ ํ˜ธ์ถœํ•˜์—ฌ ์‹คํ–‰ํ•œ๋‹ค.