-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmOp1Pop.java
186 lines (129 loc) · 4.88 KB
/
cmOp1Pop.java
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package com.company;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public class cmOp1Pop extends JFrame implements ActionListener {
protected String username;
protected String key;
protected int price;
protected boolean parking;
protected boolean wifi;
protected int size;
protected HashMap<String, String> ausers = new HashMap<String, String>();
protected HashMap<String, String> roles = new HashMap<String, String>();
protected HashMap<String, User> user = new HashMap<String, User>();
protected HashMap<String, String> rentals = new HashMap<String, String>();
protected HashMap<String, Rentable> rentalsV2 = new HashMap<String, Rentable>();
protected HashMap<String, String> rented = new HashMap<String, String>();
protected HashMap<String, String> rentcancel = new HashMap<String, String>();
protected HashMap<String, String> messages = new HashMap<String, String>();
//gui register values
private JTextField textkey;
private JLabel labelkey;
private JTextField textprice;
private JLabel labelprice;
private JTextField textpark;
private JLabel labelpark;
private JTextField textwifi;
private JLabel labelwifi;
private JTextField textsize;
private JLabel labelsize;
private JButton buttonqq;
private JLabel cr;
private int choicer = 0;
protected String howner;
/**
* <p>
*this is the gui and code for the choice to rent aroom in the client menu made with java swing
*<br>
* @param -
* @return
* @see -
* @author tsig-404
*/
public cmOp1Pop(String name,HashMap<String, String> aausers, HashMap<String, String> arentals,
HashMap<String, User> auser, HashMap<String, String> arented,
HashMap<String, Rentable> arentalsV2, HashMap<String, String> rc,
HashMap<String, String> msg, HashMap<String, String> aroles) {
//maybe get rid of them later nooo it works dont delete it
this.ausers = aausers;
this.rentals = arentals;
this.user = auser;
this.rented = arented;
this.rentalsV2 = arentalsV2;
this.rentcancel = rc;
this.messages = msg;
this.roles = aroles;
this.username=name;
//if it doesnt work
setSize(500, 500);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setLocationRelativeTo(null);
//setResizable(false);
setTitle("rent a room");
setLocationRelativeTo(null);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(true);
JPanel panel1 = new JPanel();
TitledBorder border = BorderFactory.createTitledBorder(" ");
//panel1.setVerticalTextPosition(JPanel.BOTTOM);
panel1.setBorder(border);
GridLayout layout = new GridLayout(10, 10, 10, 10);
//panel1.setLayout(layout);
labelkey = new JLabel("key:");
panel1.add(labelkey);
textkey = new JTextField("");
panel1.add(textkey);
cr = new JLabel("");
buttonqq = new JButton("rent");
buttonqq.addActionListener((ActionListener) this);
//buttonc.setText("Client");
JPanel panel2 = new JPanel();
buttonqq.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//csearch();
}
});
FlowLayout aLayout = new FlowLayout();
setLayout(aLayout);
add(buttonqq);
//add(buttonrr);
add(cr);
setVisible(true);
add(panel1, BorderLayout.CENTER);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
key = new String(textkey.getText());
if (e.getActionCommand().equals("rent")) {
//rented.put(key,username);
for (Map.Entry<String, String> uu : rentals.entrySet()) {
if (Objects.equals(key, uu.getKey())) {
this.howner = uu.getValue();
rented.put(key,username);
}
}
rentals.remove(key);
cr.setText("The room is rented");
}
}
public HashMap<String,String> getRentals()
{
//System.out.println("messages:");
System.out.println(rentals);
return this.rentals;
}
public HashMap<String,String> getRented()
{
//System.out.println("messages:");
System.out.println(rented);
return this.rented;
}
}