diff --git a/MyProject/src/hotelReservation/DeluxeRoom.java b/MyProject/src/hotelReservation/DeluxeRoom.java index 1bb6ebd..8e6a849 100644 --- a/MyProject/src/hotelReservation/DeluxeRoom.java +++ b/MyProject/src/hotelReservation/DeluxeRoom.java @@ -1,10 +1,10 @@ package hotelReservation; public class DeluxeRoom extends Room { - private int serviceFees; + private double serviceFees; - public DeluxeRoom (int roomNumber,int serviceFees) { - super (roomNumber,6990); //make service fees for Deluxe romm + public DeluxeRoom (int roomNumber,double serviceFees) { + super (roomNumber,15990.0); //make service fees for Deluxe romm this.serviceFees = serviceFees; } @Override diff --git a/MyProject/src/hotelReservation/Reception.java b/MyProject/src/hotelReservation/Reception.java index 0e335ee..9834475 100644 --- a/MyProject/src/hotelReservation/Reception.java +++ b/MyProject/src/hotelReservation/Reception.java @@ -1,16 +1,126 @@ package hotelReservation; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JRadioButton; +import javax.swing.JTextField; public class Reception { public static void main(String[] args) { - // To Male Frame In GUI - JFrame frame = new JFrame("Booking Here"); - frame.setSize(500, 600); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.setLayout(null); - frame.setVisible(true); - } + // TODO 自動生成されたメソッド・スタブ + // Swing Window ဖန်တီးခြင်း + JFrame frame = new JFrame("HOTEL BOOKING SYSYTEM"); + frame.setSize(600, 500); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLayout(null); -} + // ဧည့်သည်အမည် ထည့်ရန် စာသားအကွက် + JLabel lblName = new JLabel("GUST'S NAME:"); + lblName.setBounds(30, 30, 100, 35); + frame.add(lblName); + + JTextField txtName = new JTextField(); + txtName.setBounds(140, 30, 350, 35); + frame.add(txtName); + + // အခန်းအမျိုးအစား ရွေးချယ်ရန် (Radio Buttons) + JLabel lblRoomType = new JLabel("TYPE OF ROOM:"); + lblRoomType.setBounds(30, 70, 100, 35); + frame.add(lblRoomType); + // ဝင်ရောက်မည့်ရက် (Check-in Date) ထည့်ရန် + JLabel lblDate = new JLabel("CHECKIN DATE:"); + lblDate.setBounds(30, 140, 100, 35); + frame.add(lblDate); + + JTextField txtDate = new JTextField("2026-10-01"); // ပုံစံနမူနာ ရက်စွဲ + txtDate.setBounds(140, 140, 350, 35); + frame.add(txtDate); + + JRadioButton rbStandard = new JRadioButton("Standard (15,990 Yen/ per Night)"); + rbStandard.setBounds(140, 70, 300, 35); + rbStandard.setSelected(true); + + JRadioButton rbDeluxe = new JRadioButton("Deluxe (15,990 Yen+ServiceFees)"); + rbDeluxe.setBounds(140, 100, 300, 35); + + ButtonGroup bgRoom = new ButtonGroup(); + bgRoom.add(rbStandard); + bgRoom.add(rbDeluxe); + frame.add(rbStandard); + frame.add(rbDeluxe); + +// // နေထိုင်မည့်ရက် (Nights) ထည့်ရန် +// JLabel lblNights = new JLabel("နေထိုင်မည့်ည:"); +// lblNights.setBounds(30, 140, 100, 25); +// frame.add(lblNights); + // +// JTextField txtNights = new JTextField("1"); +// txtNights.setBounds(140, 140, 60, 25); +// frame.add(txtNights); + // နေထိုင်မည့်ရက် (Nights) နေရာကို အောက်သို့ အနည်းငယ် ရွှေ့ပါ (ဥပမာ y = 180) + JLabel lblNights = new JLabel("Night STAY:"); + lblNights.setBounds(30, 180, 350, 35); + frame.add(lblNights); + + JTextField txtNights = new JTextField("---"); + txtNights.setBounds(140, 180, 60, 35); + frame.add(txtNights); + + // ဘွတ်ကင်လုပ်ရန် ခလုတ် + JButton btnBook = new JButton("BOOK NOW"); + btnBook.setBounds(140, 230, 150, 35); + frame.add(btnBook); + + // ခလုတ်ကို နှိပ်လိုက်သည့်အခါ လုပ်ဆောင်မည့် အကြောင်းအရာ + btnBook.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + String name = txtName.getText(); + if (name.isEmpty()) { + JOptionPane.showMessageDialog(frame, "Please Enter Your Name!!", "Something Worng", JOptionPane.ERROR_MESSAGE); + return; + } + + int nights = Integer.parseInt(txtNights.getText()); + Room selectedRoom; + + // Inheritance နှင့် Polymorphism ကို အသုံးပြု၍ အခန်းအဓိပ္ပါယ်သတ်မှတ်ခြင်း + if (rbStandard.isSelected()) { + selectedRoom = new StandardRoom(101); // အခန်းနံပါတ် 101 + } else { + selectedRoom = new DeluxeRoom(201, 5000.0); // အခန်းနံပါတ် 201၊ ဝန်ဆောင်ခ 5000 ယန်း + } + + // Reservation Object ဖန်တီးခြင်း + String checkInDate = txtDate.getText(); + Reservation reservation = new Reservation(name, selectedRoom, checkInDate,nights ); + + // 予約完了 နှင့် 予約情報 ကို ပေါင်းစပ်ပြသခြင်း + String message = "BOOKING IS DONW!\n\n" + + reservation.getReservationDetails() + "\n\n" + + "THANK YOU YOUR BOOKING "+"\n"+ + "Seen You Soon" + ; + + JOptionPane.showMessageDialog(frame, message, "COMFIEND BOOKING", JOptionPane.INFORMATION_MESSAGE); + + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(frame, "Please Fill count of night", "Something Worng", JOptionPane.ERROR_MESSAGE); + } + } + }); + + // မျက်နှာပြင်ကို ပေါ်လာစေရန် + frame.setVisible(true); + + } + + } \ No newline at end of file diff --git a/MyProject/src/hotelReservation/Room.java b/MyProject/src/hotelReservation/Room.java index 351ddac..a0c3957 100644 --- a/MyProject/src/hotelReservation/Room.java +++ b/MyProject/src/hotelReservation/Room.java @@ -2,9 +2,9 @@ package hotelReservation; public class Room { protected int roomNumber; - protected int pricePerNight; + protected double pricePerNight; // Constructor - public Room (int roomNumber,int pricePreNight) { + public Room (int roomNumber,double pricePreNight) { this.roomNumber= roomNumber; this.pricePerNight = pricePreNight; } diff --git a/MyProject/src/hotelReservation/StandardRoom.java b/MyProject/src/hotelReservation/StandardRoom.java index d7b386c..04eaab3 100644 --- a/MyProject/src/hotelReservation/StandardRoom.java +++ b/MyProject/src/hotelReservation/StandardRoom.java @@ -2,7 +2,7 @@ package hotelReservation; public class StandardRoom extends Room { public StandardRoom(int roomNumber) { - super(roomNumber,1450); //make stsndar Room price for per nigh + super(roomNumber,15990); //make stsndar Room price for per nigh }