-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComprehensiveReceiptGUI.java
More file actions
83 lines (70 loc) · 2.6 KB
/
ComprehensiveReceiptGUI.java
File metadata and controls
83 lines (70 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import javax.swing.*;
import java.util.*;
public class ComprehensiveReceiptGUI implements ReceiptStrategy
{
private JFrame receiptFrame;
private JPanel userIdPanel;
//private JPanel namePanel;
private JPanel reservedRoomsPanel;
private JPanel totalDuesPanel;
private JPanel detailPanel;
private String userId;
//private String name;
private String roomNum;
private int totalDue;
private String detailRooms;
private ArrayList<Reservation> reservations;
//ComprehensiveReceiptGUI(user.getReservations());
ComprehensiveReceiptGUI(ArrayList<Reservation> reservations)
{
this.reservations = reservations;
receiptFrame = new JFrame("Comprehensive Receipt");
userIdPanel = new JPanel();
//namePanel = new JPanel();
reservedRoomsPanel = new JPanel();
totalDuesPanel = new JPanel();
detailPanel = new JPanel();
userIdPanel.add(new JLabel("User ID: "));
JTextArea userId = new JTextArea(Integer.toString(reservations.get(0).getUserId()));
userIdPanel.add(userId);
/*
namePanel.add(new JLabel("Guest Name: "));
JTextArea name = new JTextArea(reservations.get(0).getName());
namePanel.add(name);
*/
reservedRoomsPanel.add(new JLabel("Rooms to be reserved currently : "));
/*JTextArea roomNum = new JTextArea(Integer.toString(reservations.get(reservations.size() - 1).getRoomNumber()));
reservedRoomsPanel.add(roomNum);
*/for(Reservation r: reservations)
{
JLabel roomNum = new JLabel(Integer.toString(r.getRoomNumber()));
reservedRoomsPanel.add(roomNum);
}
totalDuesPanel.add(new JLabel("Total Dues for all reservations:"));
this.getTotalDues();
totalDuesPanel.add(new JLabel("$" + Integer.toString(totalDue)));
detailPanel.add(new JLabel("Rooms reservation history"));
JTextArea detailRoomsArea = new JTextArea(detailRooms);
detailPanel.add(detailRoomsArea);
this.printReceipt();
}
public void printReceipt()
{
receiptFrame.setLayout(new BoxLayout(receiptFrame.getContentPane(),BoxLayout.Y_AXIS));
//receiptFrame.add(namePanel);
receiptFrame.add(userIdPanel);
receiptFrame.add(reservedRoomsPanel);
receiptFrame.add(totalDuesPanel);
receiptFrame.add(detailPanel);
receiptFrame.pack();
receiptFrame.setVisible(true);
}
public void getTotalDues()
{
for (int i=0; i < reservations.size(); i++)
{
int reservedCharges = reservations.get(i).getCharges();
totalDue += reservedCharges;
}
}
}