-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleReceiptGUI.java
More file actions
73 lines (58 loc) · 1.97 KB
/
SimpleReceiptGUI.java
File metadata and controls
73 lines (58 loc) · 1.97 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
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class SimpleReceiptGUI implements ReceiptStrategy
{
private JFrame receiptFrame;
private JPanel userIdPanel;
private JPanel namePanel;
private JPanel reservedRoomsPanel;
private JPanel totalDuesPanel;
private String userId;
private String name;
private String roomNum;
private int totalDue;
private ArrayList<Reservation> reservations;
SimpleReceiptGUI(ArrayList<Reservation> reservations)
{
this.reservations = reservations;
receiptFrame = new JFrame("Simple Receipt");
userIdPanel = new JPanel();
namePanel = new JPanel();
reservedRoomsPanel = new JPanel();
totalDuesPanel = new JPanel();
userIdPanel.add(new JLabel("User ID: "));
JLabel userId = new JLabel(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: "));
for(Reservation r: reservations)
{
JLabel roomNum = new JLabel(Integer.toString(r.getRoomNumber()));
reservedRoomsPanel.add(roomNum);
}
totalDuesPanel.add(new JLabel("Total Dues:"));
this.getTotalDues();
totalDuesPanel.add(new JLabel("$" + Integer.toString(totalDue)));
this.printReceipt();
}
public void printReceipt()
{
receiptFrame.setLayout(new BoxLayout(receiptFrame.getContentPane(),BoxLayout.Y_AXIS));
receiptFrame.add(userIdPanel);
receiptFrame.add(namePanel);
receiptFrame.add(reservedRoomsPanel);
receiptFrame.add(totalDuesPanel);
receiptFrame.pack();
receiptFrame.setVisible(true);
}
public void getTotalDues()
{
for(Reservation r: reservations)
{
totalDue += r.getCharges();
}
}
}