commit again
This commit is contained in:
38
Exercises/src/day_2/Day2_2.java
Normal file
38
Exercises/src/day_2/Day2_2.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package day_2;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Day2_2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String[] messages = { "いまなにしてる", "何も入力されていません", "投稿文が長すぎます", "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓" };
|
||||
|
||||
Scanner scan = new Scanner(System.in);
|
||||
String str = "";
|
||||
int maxLength = 140;
|
||||
|
||||
while (true) {
|
||||
System.out.println(messages[0]);
|
||||
str = scan.nextLine().replace(" ", "").replace(" ", "");
|
||||
|
||||
// 早期リターン (Early Return / Guard Clause) ကို အသုံးပြု၍ ချက်ချင်းစစ်ဆေးခြင်း
|
||||
if (str.isEmpty()) {
|
||||
System.out.println(messages[1]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str.length() > maxLength) {
|
||||
System.out.println(messages[2]);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
System.out.println(messages[3]);
|
||||
System.out.println(str);
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
||||
BIN
MyProject/src/doc/HotelReceptionProject1.drawio.pdf
Normal file
BIN
MyProject/src/doc/HotelReceptionProject1.drawio.pdf
Normal file
Binary file not shown.
19
MyProject/src/hotelReservation/DeluxeRoom.java
Normal file
19
MyProject/src/hotelReservation/DeluxeRoom.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package hotelReservation;
|
||||
|
||||
public class DeluxeRoom extends Room {
|
||||
private int serviceFees;
|
||||
|
||||
public DeluxeRoom (int roomNumber,int serviceFees) {
|
||||
super (roomNumber,6990); //make service fees for Deluxe romm
|
||||
this.serviceFees = serviceFees;
|
||||
}
|
||||
@Override
|
||||
public double calculateTotal (int nights) {
|
||||
return (pricePerNight*nights)+serviceFees;
|
||||
}
|
||||
@Override
|
||||
public String getRoomInfo() {
|
||||
return "Delixe Room Number" +roomNumber+ "includeing Service Fees";
|
||||
}
|
||||
|
||||
}
|
||||
16
MyProject/src/hotelReservation/Reception.java
Normal file
16
MyProject/src/hotelReservation/Reception.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package hotelReservation;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
29
MyProject/src/hotelReservation/Reservation.java
Normal file
29
MyProject/src/hotelReservation/Reservation.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package hotelReservation;
|
||||
|
||||
public class Reservation {
|
||||
private String guestName;
|
||||
private Room room;
|
||||
private String checkInDay;
|
||||
private int nights;
|
||||
|
||||
public Reservation(String gustName, Room room, String checkInDay, int nights) {
|
||||
this.guestName = gustName;
|
||||
this.room = room;
|
||||
this.checkInDay = checkInDay;
|
||||
this.nights = nights;
|
||||
}
|
||||
|
||||
// Detail of Booking information (so se should be make new object {totalCost}
|
||||
// from room calculate **from override
|
||||
public String getReservationDetails() {
|
||||
double totalCost = room.calculateTotal(nights);
|
||||
return "===== BOOKIN DETAILS =====\n" +
|
||||
"GUEST NAME :" + guestName + "\n" +
|
||||
"CHECKIN DATE :" + checkInDay + "\n" +
|
||||
room.getRoomInfo() + "\n" +
|
||||
"STAY:" + nights + " night\n" +
|
||||
"TOTAL AMMOUNT :" + totalCost + "Yen\n";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
20
MyProject/src/hotelReservation/Room.java
Normal file
20
MyProject/src/hotelReservation/Room.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package hotelReservation;
|
||||
|
||||
public class Room {
|
||||
protected int roomNumber;
|
||||
protected int pricePerNight;
|
||||
// Constructor
|
||||
public Room (int roomNumber,int pricePreNight) {
|
||||
this.roomNumber= roomNumber;
|
||||
this.pricePerNight = pricePreNight;
|
||||
}
|
||||
//1 ammount for every room
|
||||
public double calculateTotal (int nights) { //this method will be override in otherclass
|
||||
return pricePerNight*nights;
|
||||
}
|
||||
//Show Info for firt time
|
||||
public String getRoomInfo() { //this method will be override in otherclass
|
||||
return "Room Number"+ roomNumber+"Per Night"+pricePerNight;
|
||||
|
||||
}
|
||||
}
|
||||
9
MyProject/src/hotelReservation/StandardRoom.java
Normal file
9
MyProject/src/hotelReservation/StandardRoom.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package hotelReservation;
|
||||
|
||||
public class StandardRoom extends Room {
|
||||
public StandardRoom(int roomNumber) {
|
||||
super(roomNumber,1450); //make stsndar Room price for per nigh
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user