Skip to content

Commit 3ba03e3

Browse files
Merge pull request #55 from EhsanulHaqueSiam/terminalState
feat: CheckIn terminal state updated
2 parents afa6c10 + 3d8e100 commit 3ba03e3

22 files changed

+232
-32
lines changed

files/rooms.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Booked
105105

106106
Rooms Details
107107
218
108-
Non-Ac
109-
Double
110-
2000
108+
AC
109+
Single
110+
120
111111
Not Booked
112112

files/user_login.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Full Name : Aonyendo Paul
33
User Name : Paul
44
Password : 2134
5-
Phone : 01912345678
5+
Phone : 01616781123
66
Time & Date : 23:28 PM, 13/05/2023
77
===============================================
88
===============================================
@@ -25,3 +25,10 @@ Password : 0000
2525
Phone : 01818080896
2626
Time & Date : 17:16 PM, 16/05/2023
2727
===============================================
28+
===============================================
29+
Full Name : Mindu sen
30+
User Name : Mindu
31+
Password : 1234
32+
Phone : 01818080896
33+
Time & Date : 17:30 PM, 14/06/2023
34+
===============================================

myClasses/BkashPayment.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class BkashPayment extends JFrame implements ActionListener, ConfirmPayme
2424
* It initializes the JFrame and adds components to it.
2525
*/
2626
BkashPayment() {
27+
System.out.println("Currently in BkashPayment class");
2728
// Set JFrame properties
2829
setTitle("Bkash Payment");
2930
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@@ -94,12 +95,14 @@ public void actionPerformed(ActionEvent ae) {
9495
// Navigate back to Payment page
9596
new Payment();
9697
this.setVisible(false);
98+
System.out.println("Exited from BkashPayment class");
9799
} else if (ae.getSource() == next_btn) {
98100
// Check if MobileNumber and Pin are empty
99101
boolean isMobileNumberEmpty = MobileNumber.isEmpty();
100102
boolean isPinEmpty = Pin.isEmpty();
101103
// Call confirmPayment method with input values and current instance
102104
confirmPayment(isMobileNumberEmpty, isPinEmpty, this, num_fld, pass_fld);
105+
103106
}
104107
}
105108

@@ -115,19 +118,25 @@ public void actionPerformed(ActionEvent ae) {
115118
*/
116119
@Override
117120
public void confirmPayment(boolean isMobileNumberEmpty, boolean isPinEmpty, JFrame paymentFrame, JTextField number, JPasswordField password) {
121+
System.out.println("confirmPayment function called");
118122
if (isMobileNumberEmpty) {
119123
JOptionPane.showMessageDialog(null, "Invalid Phone number ");
124+
System.out.println("Number field is empty");
120125
} else {
121126
if (isPinEmpty) {
122127
JOptionPane.showMessageDialog(null, "Invalid Pin");
128+
System.out.println("Pin number is invalid");
123129
} else {
124130
if (inputValidation(number, password) && inputLength(number, password)) {
125131
JOptionPane.showMessageDialog(null, "Payment Confirmed\nThank You For Staying At Tipton");
132+
System.out.println("Payment Done Successfully");
126133
new UDashBoard();
127134
paymentFrame.setVisible(false);
135+
System.out.println("Exited from BkashPayment class");
128136
}
129137
}
130138
}
139+
System.out.println("confirmPayment funtion executed successfully");
131140
}
132141

133142
/**
@@ -140,6 +149,7 @@ public void confirmPayment(boolean isMobileNumberEmpty, boolean isPinEmpty, JFra
140149
*/
141150
@Override
142151
public boolean inputValidation(JTextField number, JPasswordField password) {
152+
System.out.println("inputValidation funtion called");
143153
boolean n = true;
144154
boolean p = true;
145155
String numberText = number.getText();
@@ -169,7 +179,8 @@ public boolean inputValidation(JTextField number, JPasswordField password) {
169179
JOptionPane.showMessageDialog(null, "Pin number cannot contain characters", "Pin number error", JOptionPane.WARNING_MESSAGE);
170180
return false;
171181
}
172-
return true;
182+
System.out.println("inputValtidation funtion executed successfully");
183+
return true;
173184
}
174185

175186
/**
@@ -182,6 +193,7 @@ public boolean inputValidation(JTextField number, JPasswordField password) {
182193
*/
183194
@Override
184195
public boolean inputLength(JTextField number, JPasswordField password) {
196+
System.out.println("inputLength funtion called");
185197
String numberText = number.getText();
186198
String passText = String.valueOf(password.getPassword());
187199

@@ -196,6 +208,7 @@ public boolean inputLength(JTextField number, JPasswordField password) {
196208
return false;
197209
}
198210

211+
System.out.println("inputLength funtion executed successfully");
199212
return true;
200213
}
201214
}

myClasses/CheckIn.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class CheckIn extends ShowRoom implements ActionListener,myInterface.Writ
3636
public String roomNo;
3737

3838
public CheckIn() {
39+
System.out.println("Currently in CheckIn class");
3940
frame = new JFrame();
4041
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
4142
frame.setBounds(100, 100, 927, 533);
@@ -240,6 +241,7 @@ public void actionPerformed(ActionEvent e) {
240241
if (e.getSource() == back_btn) {
241242
// Navigate back to the dashboard
242243
frame.setVisible(false);
244+
System.out.println("Exited from CheckIn class");
243245
new DashBoard();
244246
} else if (e.getSource() == logOut_Btn) {
245247
// Prompt for confirmation and logout if confirmed
@@ -248,6 +250,7 @@ public void actionPerformed(ActionEvent e) {
248250
if (yesORno == JOptionPane.YES_OPTION) {
249251
// Logout and show the login screen
250252
frame.setVisible(false);
253+
System.out.println("Exited from CheckIn class");
251254
new Login();
252255
}
253256
} else if (e.getSource() == clear_btn) {
@@ -261,6 +264,7 @@ public void actionPerformed(ActionEvent e) {
261264
gender_Box.setSelectedIndex(0);
262265
bed_Box.setSelectedIndex(0);
263266
roomType_Box.setSelectedIndex(0);
267+
System.out.println("All data cleared from Text Field and Combo Box set to Default");
264268
} else if (e.getSource() == confirm_btn) {
265269
if (!isNameFieldEmpty && !isMobileNumberFieldEmpty && !isNationalityFieldEmpty && !isGmailEmpty && !isAddressEmpty && !isCheckinDateEmptyField && !isCostFieldEmpty) {
266270

@@ -309,21 +313,28 @@ public void actionPerformed(ActionEvent e) {
309313
String roomNo = Objects.requireNonNull(roomNo_Box.getSelectedItem()).toString();
310314
// Create a temporary file to write updated data to
311315
File tempFile = new File("./files/temp.txt");
316+
System.out.println("temp file created");
312317
PrintWriter pw = new PrintWriter(new FileWriter(tempFile));
318+
System.out.println("Writting into temp file");
313319
BufferedReader br = new BufferedReader(new FileReader("./files/rooms.txt"));
320+
System.out.println("Reading from room.txt");
314321
String line2;
315322
while ((line2 = br.readLine()) != null) {
316323
if (line2.equals("Rooms Details")) {
317324
String[] rowData = new String[5]; // create an array with 5 elements
318325
for (int i = 0; i < 5; i++) {
319326
// read the next 5 lines and add the data to the corresponding column
320327
rowData[i] = br.readLine();
328+
System.out.println("reading room.txt");
321329
}
322330
if (rowData[0].equals(roomNo)) { // if the room number is a match
331+
System.out.println("Room found");
323332
rowData[4] = "Booked"; // update the status
333+
System.out.println("Updated room status to Booked");
324334
}
325335
// write the updated row data to the temporary file
326336
pw.println("Rooms Details");
337+
System.out.println("Updating data to temp file");
327338
for (int i = 0; i < 5; i++) {
328339
pw.println(rowData[i]);
329340
}
@@ -351,7 +362,8 @@ public void actionPerformed(ActionEvent e) {
351362
}
352363

353364

354-
JOptionPane.showMessageDialog(null, "Congratulation Check In successful", "Congratulation", JOptionPane.INFORMATION_MESSAGE);
365+
JOptionPane.showMessageDialog(null, "Congratulation Check In successfully", "Congratulation", JOptionPane.INFORMATION_MESSAGE);
366+
System.out.println("Check in done successfully");
355367
// Clearing the input fields
356368
name_field.setText(null);
357369
mbl_fld.setText(null);
@@ -362,6 +374,8 @@ public void actionPerformed(ActionEvent e) {
362374
gender_Box.setSelectedIndex(0);
363375
bed_Box.setSelectedIndex(0);
364376
roomType_Box.setSelectedIndex(0);
377+
System.out.println("All data cleared from Text Field and Combo Box set to Default");
378+
365379
} catch (Exception ex) {
366380
ex.printStackTrace();
367381
}
@@ -422,6 +436,7 @@ public void actionPerformed(ActionEvent e) {
422436
*/
423437
@Override
424438
public void WriteCheckinData(String nationality, String gmail, String address, String CheckInDate, String cost, String gender, String roomNo_B, File file, String fullName, String mobileNumber) throws IOException {
439+
System.out.println("WriteCheckinData funtion called");
425440
FileWriter fileWriter = new FileWriter(file, true);
426441
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
427442
PrintWriter printWriter = new PrintWriter(bufferedWriter);
@@ -440,6 +455,8 @@ public void WriteCheckinData(String nationality, String gmail, String address, S
440455
printWriter.println();
441456

442457
printWriter.close();
458+
System.out.println("WriteCheckinData funtion executed successfully");
459+
System.out.println("New checkIn data stored successfully");
443460
}
444461

445462

myClasses/CheckOut.java

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import myInterface.ClearCheckOut;
44

5+
import javax.sound.sampled.SourceDataLine;
56
import javax.swing.*;
67
import javax.swing.border.EmptyBorder;
78
import javax.swing.table.DefaultTableCellRenderer;
@@ -47,7 +48,7 @@ public class CheckOut extends JFrame implements ActionListener, myInterface.Clea
4748

4849

4950
public CheckOut() {
50-
51+
System.out.println("Currently in CheckOut class");
5152
setResizable(false);
5253
setTitle("Admin checkout");
5354
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@@ -255,18 +256,21 @@ public void actionPerformed(ActionEvent e) {
255256
if (yesORno == JOptionPane.YES_OPTION) {
256257
// Hide current window and show login window
257258
this.setVisible(false);
259+
System.out.println("Exited from CheckOut class");
258260
new Login();
259261
}
260262
} else if (e.getSource() == back_btn) { // Back button action
261263
// Hide current window and show dashboard window
262264
setVisible(false);
265+
System.out.println("Exited from CheckOut class");
263266
new DashBoard();
264267
} else if (e.getSource() == clear_btn) { // Clear button action
265268
// Clear checkout fields and adjust table column widths
266269
ClearCheckOut.ClearCheckoutField(CustomerName_fld, CustomerNum_fld, checkInDate_fld, pricePerDay_fld, dayStay_fld, totalAmount_fld, email_fld, search_combo, table);
267270

268271
table.getColumnModel().getColumn(0).setPreferredWidth(80);
269272
table.getColumnModel().getColumn(1).setPreferredWidth(82);
273+
System.out.println("All data cleared from Text Field and Combo Box set to Default");
270274
}else if (e.getSource() == checkOut_btn) {
271275
if(search_combo.getSelectedItem() == null){ //Show error if Search bar is Empty
272276
JOptionPane.showMessageDialog(null, "Error", "No room is selected", JOptionPane.WARNING_MESSAGE);
@@ -277,6 +281,7 @@ public void actionPerformed(ActionEvent e) {
277281
String roomNo = (String) search_combo.getSelectedItem();
278282
// Create a temporary file to write updated data to
279283
File tempFile = new File("./files/temp.txt");
284+
System.out.println("temp.txt file created");
280285
PrintWriter pw = new PrintWriter(new FileWriter(tempFile));
281286
BufferedReader br = new BufferedReader(new FileReader("./files/rooms.txt"));
282287
String line2;
@@ -288,10 +293,13 @@ public void actionPerformed(ActionEvent e) {
288293
rowData[i] = br.readLine();
289294
}
290295
if (rowData[0].equals(roomNo)) { // if the room number is a match
296+
System.out.println("Room number found");
291297
rowData[4] = "Not Booked"; // update the status
298+
System.out.println("Updated room details to Not Booked");
292299
}
293300
// write the updated row data to the temporary file
294301
pw.println("Rooms Details");
302+
System.out.println("Updated details to temp file");
295303
for (int i = 0; i < 5; i++) {
296304
pw.println(rowData[i]);
297305
}
@@ -305,8 +313,15 @@ public void actionPerformed(ActionEvent e) {
305313
// Replace the original file with the temporary file
306314
File originalFile = new File("./files/rooms.txt");
307315
if (originalFile.delete()) {
308-
tempFile.renameTo(originalFile);
309-
}
316+
boolean renamed = tempFile.renameTo(originalFile);
317+
if (renamed) {
318+
System.out.println("File renamed successfully.");
319+
} else {
320+
System.out.println("Failed to rename the file.");
321+
}
322+
} else {
323+
System.out.println("Failed to delete the original file.");
324+
}
310325
} catch (Exception ex) {
311326
ex.printStackTrace();
312327
}
@@ -316,7 +331,7 @@ public void actionPerformed(ActionEvent e) {
316331
deleteRoomEntry();
317332

318333
JOptionPane.showMessageDialog(null, "Check Out Successful", "Check Out", JOptionPane.INFORMATION_MESSAGE);
319-
334+
System.out.println("CheckOut Done Successfully");
320335
ClearCheckOut.ClearCheckoutField(CustomerName_fld, CustomerNum_fld, checkInDate_fld, pricePerDay_fld, dayStay_fld, totalAmount_fld, email_fld, search_combo, table);
321336

322337
// Clearing the input fields
@@ -337,6 +352,7 @@ public void actionPerformed(ActionEvent e) {
337352
roomSearch();
338353
search_combo.setSelectedIndex(-1);
339354
ClearCheckOut.ClearCheckoutField(CustomerName_fld, CustomerNum_fld, checkInDate_fld, pricePerDay_fld, dayStay_fld, totalAmount_fld, email_fld, search_combo, table);
355+
System.out.println("All data cleared from Text Field and Combo Box set to Default");
340356
}
341357
}
342358

@@ -370,11 +386,14 @@ public void actionPerformed(ActionEvent e) {
370386
}
371387
// Check if the room exists
372388
if (DoesRoomExists) {
389+
System.out.println("Room Exist");
373390
// Retrieve customer data
374391
getCustomerData();
392+
System.out.println("Customer Data Retrived");
375393
} else {
376394
// Display an error message if the room is not found
377395
JOptionPane.showMessageDialog(null, "room not found", "Error", JOptionPane.WARNING_MESSAGE);
396+
System.out.println("Room Doesn't not exist");
378397
search_combo.setSelectedIndex(-1);
379398

380399
}
@@ -417,9 +436,11 @@ public void actionPerformed(ActionEvent e) {
417436

418437
@Override
419438
public void deleteRoomEntry() {
439+
System.out.println("deleteRoomEntry funtion called");
420440
try {
421441
File inputFile = new File("./files/checkIn.txt");
422442
File tempFile = new File("./files/checkIn_temp.txt");
443+
System.out.println("temp file created");
423444

424445
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
425446
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
@@ -446,6 +467,7 @@ public void deleteRoomEntry() {
446467
// write all other lines to the temp file
447468

448469
writer.write(currentLine + System.getProperty("line.separator"));
470+
System.out.println("writting into temp file");
449471

450472
}
451473
}
@@ -455,17 +477,21 @@ public void deleteRoomEntry() {
455477

456478
// delete the original file
457479
inputFile.delete();
480+
System.out.println("Orginal file deleted");
458481

459482
// rename the temp file to the original file name
460483
tempFile.renameTo(inputFile);
484+
System.out.println("temp file renamed to orginal file");
461485

462486
} catch (IOException ex) {
463487
ex.printStackTrace();
464488
}
489+
System.out.println("deleteRoomEntry funtion executed successfully");
465490
}
466491

467492
@Override
468493
public void getCustomerData() {
494+
System.out.println("getCustomerData funtion called");
469495
DefaultTableModel model;
470496
model = (DefaultTableModel) table.getModel();
471497
model.setRowCount(0);
@@ -539,9 +565,12 @@ public void getCustomerData() {
539565
CustomerNum_fld.setText(mobileNumber);
540566
pricePerDay_fld.setText(roomPrice);
541567
email_fld.setText(gmail);
568+
569+
System.out.println("getCustomerData funtion executed successfully");
542570
}
543571

544572
public void roomSearch() {
573+
System.out.println("roomSearch funtion called");
545574
try (BufferedReader br = new BufferedReader(new FileReader("./files/rooms.txt"))) {
546575
String line;
547576
while ((line = br.readLine()) != null) {
@@ -559,6 +588,8 @@ public void roomSearch() {
559588
} catch (Exception e) {
560589
e.printStackTrace();
561590
}
591+
592+
System.out.println("roomSearch funtion executed successfully");
562593
}
563594

564595
}

0 commit comments

Comments
 (0)