-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
281 lines (192 loc) · 7.5 KB
/
Main.java
File metadata and controls
281 lines (192 loc) · 7.5 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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
package sample;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Main extends Application {
// Category 1
Label BreakFast_Category1;
CheckBox CheckBox1;
CheckBox CheckBox2;
CheckBox CheckBox3;
// Category 2
Label Lunch_Category2;
CheckBox CheckBox4;
CheckBox CheckBox5;
CheckBox CheckBox6;
// Category3
Label Dinner_Category3;
CheckBox CheckBox7;
CheckBox CheckBox8;
CheckBox CheckBox9;
//Text Area
TextArea OutputTextArea;
//Array list to insert selected items
ArrayList<String> SelectedList= new ArrayList<>();
Boolean isOrdered= false;
@Override
public void start(Stage stage) throws Exception{
BreakFast_Category1 = new Label("BreakFast1");
CheckBox1 = new CheckBox("Freid Egg" + "\t"+ "D40");
CheckBox2 = new CheckBox ("Egg Rapp" + "\t"+ "D60");
CheckBox3 = new CheckBox(" Chicken Rapp" + "\t"+ "D80");
VBox Pane_Categorie1 = new VBox(BreakFast_Category1, CheckBox1,CheckBox2,CheckBox3);
Pane_Categorie1.setSpacing(10);
Lunch_Category2= new Label("Lunch");
CheckBox4 = new CheckBox("Benachine"+ "\t"+ "D100");
CheckBox5 = new CheckBox ("Domoda"+ "\t"+ "D100");
CheckBox6 = new CheckBox(" Mbahal" + "\t"+ "D75");
VBox Pane_Categorie2 = new VBox(Lunch_Category2, CheckBox4,CheckBox5,CheckBox6);
Pane_Categorie2.setSpacing(10);
Dinner_Category3= new Label("Dinner");
CheckBox7 = new CheckBox("Icecream" + "\t"+ "D50");
CheckBox8 = new CheckBox ("Youghurt" + "\t"+ "D75");
CheckBox9 = new CheckBox(" Pourage"+ "\t"+ "D50");
VBox pane_Categorie3 = new VBox(Dinner_Category3, CheckBox7,CheckBox8,CheckBox9);
pane_Categorie3.setSpacing(10);
Button OrderBtn = new Button();
Button RefreshButton = new Button();
Button Save = new Button();
RefreshButton.setText("Refresh");
OrderBtn.setText("Oder");
Save.setText("Save");
OrderBtn.setOnAction(e -> OderBtn_Click());
RefreshButton.setOnAction(e -> RefreshButton_Clicked());
RefreshButton.setOnAction(e -> RefreshButton_Clicked());
HBox PaneButton = new HBox(10,OrderBtn,RefreshButton, Save);
PaneButton.setAlignment(Pos.BOTTOM_LEFT);
OutputTextArea = new TextArea("");
HBox OutputTextAreaa = new HBox(OutputTextArea);
OutputTextArea.setEditable(false);
OutputTextAreaa.setPrefWidth(500);
OutputTextAreaa.setPrefHeight(250);
HBox paneBottom = new HBox(10, OutputTextAreaa);
paneBottom.setSpacing(10);
paneBottom.setAlignment(Pos.BASELINE_CENTER);
paneBottom.setPadding(new Insets(50));
HBox PaneOder = new HBox( 50,Pane_Categorie1,Pane_Categorie2, pane_Categorie3,PaneButton);
//
VBox PaneCentre = new VBox(PaneOder);
PaneCentre.setPadding(new Insets(20,50,20,75));
BorderPane Painmain = new BorderPane();
Painmain.setCenter(PaneCentre);
Painmain.setBottom(paneBottom);
// Ui for category one
// set pane in stage
Group root = new Group();
stage.setTitle("Food Order system");
Scene scene = new Scene(root, Color.GRAY);
Scene scene2 = new Scene(Painmain);
stage.setScene(scene);
stage.setScene(scene2);
stage.setTitle("Food Odering system");
stage.setHeight(500);
stage.setWidth(800);
stage.setResizable(false);
stage.show();
}
private void RefreshButton_Clicked() {
CheckBox1.setSelected(false);
CheckBox2.setSelected(false);
CheckBox3.setSelected(false);
CheckBox4.setSelected(false);
CheckBox5.setSelected(false);
CheckBox6.setSelected(false);
CheckBox7.setSelected(false);
CheckBox8.setSelected(false);
CheckBox9.setSelected(false);
OutputTextArea.clear();
}
private void OderBtn_Click() {
String Selected_ = "";
double Total = 0;
String newLine = "\n";
String tTab = "\t";
if (CheckBox1.isSelected()) {
Selected_ = CheckBox1.getText();
SelectedList.add(Selected_);
Total = 40;
}
if (CheckBox2.isSelected()) {
Selected_ = CheckBox2.getText();
SelectedList.add(Selected_);
Total = Total + 60;
}
if (CheckBox3.isSelected()) {
Selected_ = CheckBox3.getText();
SelectedList.add(Selected_);
Total = Total + 80;
}
if (CheckBox4.isSelected()) {
Selected_ = CheckBox4.getText();
SelectedList.add(Selected_);
Total = Total + 100;
}
if (CheckBox5.isSelected()) {
Selected_ = CheckBox5.getText();
SelectedList.add(Selected_);
Total = Total + 100;
}
if (CheckBox6.isSelected()) {
Selected_ = CheckBox6.getText();
SelectedList.add(Selected_);
Total = Total + 75;
}
if (CheckBox7.isSelected()) {
Selected_ = CheckBox7.getText();
SelectedList.add(Selected_);
Total = Total + 50;
}
if (CheckBox8.isSelected()) {
Selected_ = CheckBox8.getText();
SelectedList.add(Selected_);
Total = Total + 75;
}
if (CheckBox9.isSelected()) {
Selected_ = CheckBox9.getText();
SelectedList.add(Selected_);
Total = Total + 50;
}
if (SelectedList.isEmpty()) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Erro message");
alert.setHeaderText("Erro Message");
alert.setContentText("Please select checkbox to Order");
alert.showAndWait();
}
StringBuffer sb = new StringBuffer();
for (String s : SelectedList) {
sb.append(s);
sb.append("\n");
}
String str = sb.toString();
isOrdered= true;
OutputTextArea.setText(str + newLine + " Your Total is " + Total + newLine +
" Thank you for odering have a nice meal" + newLine);
}
public static void main(String[] args) {
launch(args);
}
}