-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainClass Proj
733 lines (606 loc) · 36.2 KB
/
MainClass Proj
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
package com.example.demo6;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.example.demo6.CartView.*;
public class MainClass extends Application {
List<String> flowerNames = new ArrayList<>(Arrays.asList("Rose", "Tulip", "Daisy", "Carnation", "Daffodils", "Lily", "Sunflower"));
List<String> bookNames = new ArrayList<>(Arrays.asList(
"It ends with us",
"Little Women",
"Harry Potter",
"Pride and Prejudice",
"Emma",
"Milenal",
"All the light we cannot see",
"Great Expectations",
"Bringing down the duke"
));
//making of first page aka homepage
private Scene homepageScene;
public void start(Stage primaryStage) {
BorderPane root = new BorderPane();
root.setStyle("-fx-background-color: #f5f5dc;"); // Color for our bg
// Header
VBox header = new VBox();
header.setStyle("-fx-background-color: #8B4513; -fx-padding: 20px;"); // Brown color header
header.setAlignment(Pos.CENTER);
Text title = new Text("Evermore Hearth");
title.setFont(Font.font("Georgia", 36));
title.setFill(Color.WHITE);
Text caption = new Text("A cup, a moment, a heaven");
caption.setFont(Font.font("Georgia", FontPosture.ITALIC, 18));
caption.setFill(Color.LIGHTGOLDENRODYELLOW);
header.getChildren().addAll(title, caption);
root.setTop(header);
// our first page
GridPane mainContent = new GridPane();
mainContent.setHgap(20); // Horizontal spacing
mainContent.setVgap(20); // Vertical spacing
mainContent.setAlignment(Pos.CENTER);
mainContent.setPadding(new Insets(20));
// Hot Section
VBox hotSection = createSection("Hot", "Explore our warm and cozy beverages.", "C:\\Users\\LENOVO\\Downloads\\hotcoffenewimage.jpg", primaryStage); //method called
// Cold Section
VBox coldSection = createSection("Cold", "Indulge in our refreshing and chilled drinks.", "C:\\Users\\LENOVO\\Downloads\\coldcofeeimage.jpg", primaryStage);
//Flower Section
VBox flowerSection=createSection("Flowers","Bringing blooms and joy, one petal at a time!","C:\\Users\\LENOVO\\Downloads\\flower section image2.jpg",primaryStage);
//Book Section
VBox bookSection=createSection("Books","In the realm of written beauty","C:\\Users\\LENOVO\\Downloads\\mainbookspage.jpeg",primaryStage);
mainContent.add(hotSection, 0, 0);
mainContent.add(coldSection, 1, 0);
mainContent.add(flowerSection, 0, 1);
mainContent.add(bookSection, 1, 1);
// Set GridPane as the center of the BorderPane
ScrollPane scrollPane = new ScrollPane(mainContent);
scrollPane.setFitToWidth(true); // Make it adjust to the window width
scrollPane.setStyle("-fx-background: transparent; -fx-background-color: transparent;");
// Set ScrollPane as the center of the BorderPane
root.setCenter(scrollPane);
// Footer
VBox footer = new VBox();
footer.setStyle("-fx-background-color: #d2b48c; -fx-padding: 20px;"); // light brown color for footer
footer.setAlignment(Pos.CENTER);
Text footerText = new Text("Happiness at the click of a button");
footerText.setFont(Font.font("Georgia", 18));
footer.getChildren().add(footerText);
root.setBottom(footer);
// Scene and Stage
homepageScene = new Scene(root, 1000, 700);
primaryStage.setTitle("Evermore Cafe Homepage");
primaryStage.setScene(homepageScene);
primaryStage.show();
}
//making of sections
private VBox createSection(String title, String description, String imagePath, Stage primaryStage) { //method defined
VBox section = new VBox(10);
section.setStyle("-fx-background-color: #fff; -fx-border-color: #8B4513; -fx-border-width: 2px; -fx-padding: 10px;");
section.setPadding(new Insets(20));
// Image
ImageView imageView = new ImageView(new Image("file:" + imagePath));
imageView.setFitWidth(300);
imageView.setFitHeight(300);
imageView.setPreserveRatio(true);
// Text
Text sectionTitle = new Text(title);
sectionTitle.setFont(Font.font("Georgia", 24));
sectionTitle.setFill(Color.BROWN);
Text sectionDescription = new Text(description);
sectionDescription.setFont(Font.font("Cookie", 14));
sectionDescription.setFill(Color.CHOCOLATE);
// Button
Button exploreButton = new Button("Explore");
exploreButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px;");
exploreButton.setOnAction(e -> navigateToSection(primaryStage, title)); //method called
section.setAlignment(Pos.CENTER);
section.getChildren().addAll(sectionTitle, sectionDescription, imageView, exploreButton);
return section;
}
//navigating from one page to other
private void navigateToSection(Stage primaryStage, String sectionTitle) { //method defined
VBox sectionPage = new VBox();
sectionPage.setAlignment(Pos.CENTER);
sectionPage.setPadding(new Insets(20)); //space between objects
sectionPage.setStyle("-fx-background-color: #f5f5dc;");
Text sectionText = new Text(sectionTitle + " Section");
sectionText.setFont(Font.font("Georgia", 28));
sectionText.setFill(Color.BROWN);
TilePane productGrid = new TilePane();
productGrid.setHgap(40);
productGrid.setVgap(40);
productGrid.setPrefColumns(3);
productGrid.setPadding(new Insets(40));
productGrid.setAlignment(Pos.CENTER);
if (sectionTitle.equalsIgnoreCase("Hot")) {
productGrid.getChildren().addAll(
createProductItem("Espresso", "C:\\Users\\LENOVO\\Downloads\\espresso option1.jpg", primaryStage), //method called
createProductItem("Cortado", "C:\\Users\\LENOVO\\Downloads\\final cortado.jpg", primaryStage),
createProductItem("Flat White", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\FlatWhite.jpeg", primaryStage),
createProductItem("Americano", "C:\\Users\\LENOVO\\Downloads\\americano.jpeg", primaryStage),
createProductItem("Irish Coffee", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\IrishCoffee.jpeg", primaryStage),
createProductItem("Turkish Coffee", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\TurkishCoffee.jpeg", primaryStage),
createProductItem("Long Black", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\LongBlack.jpeg", primaryStage),
createProductItem("Mocha", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\Mocha.jpeg", primaryStage)
);
} else if (sectionTitle.equalsIgnoreCase("Cold")) {
productGrid.getChildren().addAll(
createProductItem("Cold Brew", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\ColdBrew.jpeg", primaryStage),
createProductItem("Cafe Macchiato", "C:\\Users\\LENOVO\\Downloads\\macchiato.jpg", primaryStage),
createProductItem("Iced Americano", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\IcedAmericano.jpeg", primaryStage),
createProductItem("Iced Mocha", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\IcedMocha.jpeg", primaryStage),
createProductItem("Iced Latte", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\IcedLatte.jpeg", primaryStage),
createProductItem("Iced Vanilla Latte", "C:\\Users\\LENOVO\\Downloads\\iced vanilla latte.jpeg", primaryStage),
createProductItem("Dalgona Iced Coffee", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\Dalgona.jpeg", primaryStage),
createProductItem("Caramel Iced Latte", "C:\\Users\\LENOVO\\Downloads\\iced caramel latte option2.jpg", primaryStage),
createProductItem("Salted Caramel", "C:\\Users\\LENOVO\\Downloads\\shop\\shop\\SaltedCaramel.jpeg", primaryStage)
);
}else if(sectionTitle.equalsIgnoreCase("Flowers")){
productGrid.getChildren().addAll(
createProductItem("Rose", "C:\\Users\\LENOVO\\Downloads\\rosepic.jpeg", primaryStage),
createProductItem("Tulip", "C:\\Users\\LENOVO\\Downloads\\tulip.jpeg", primaryStage),
createProductItem("Daisy", "C:\\Users\\LENOVO\\Downloads\\daisy.jpeg", primaryStage),
createProductItem("Carnation", "C:\\Users\\LENOVO\\Downloads\\carnation.jpeg", primaryStage),
createProductItem("Daffodils", "C:\\Users\\LENOVO\\Downloads\\daffodils.jpeg", primaryStage),
createProductItem("Lily", "C:\\Users\\LENOVO\\Downloads\\lily.jpeg", primaryStage),
createProductItem("Sunflower", "C:\\Users\\LENOVO\\Downloads\\sunflower.jpeg", primaryStage)
);
}else if(sectionTitle.equalsIgnoreCase("Books")){
productGrid.getChildren().addAll(
createProductItem("It ends with us", "C:\\Users\\LENOVO\\Downloads\\ITENDSWITHUSNEW.jpeg", primaryStage),
createProductItem("Little Women", "C:\\Users\\LENOVO\\Downloads\\little women.jpg", primaryStage),
createProductItem("Harry Potter", "C:\\Users\\LENOVO\\Downloads\\harry potter.jpg", primaryStage),
createProductItem("Pride and Prejudice", "C:\\Users\\LENOVO\\Downloads\\pride and prejudice.jpg", primaryStage),
// createProductItem("Emma", "file:C:/Users/hp/Downloads/project/emma.jpg", primaryStage),
createProductItem("Milenal", "C:\\Users\\LENOVO\\Downloads\\Milenal.jpg", primaryStage),
createProductItem("All the light we cannot see", "C:\\Users\\LENOVO\\Downloads\\all the light we cannot see.jpg", primaryStage),
createProductItem("Great Expectations", "C:\\Users\\LENOVO\\Downloads\\great expectations.jpg", primaryStage),
createProductItem("Bringing down the duke", "C:\\Users\\LENOVO\\Downloads\\bringing down the duke.jpg", primaryStage)
);
}
Button backButton = new Button("Back to Homepage");
backButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px;");
backButton.setOnAction(e -> primaryStage.setScene(homepageScene)); //takes you back to the homepage
sectionPage.getChildren().addAll(sectionText, productGrid, backButton);
//creates page for hot and cold menu
Scene sectionScene = new Scene(sectionPage, 1000, 700);
System.out.println("Switching to Section: " + sectionTitle);
primaryStage.setScene(sectionScene);
}
private VBox createProductItem(String title, String imagePath, Stage primaryStage) { //method defined
VBox productItem = new VBox(10);
productItem.setAlignment(Pos.CENTER);
ImageView productImage = new ImageView(new Image(imagePath));
productImage.setFitWidth(175);
productImage.setFitHeight(175);
productImage.setPreserveRatio(true);
Label productLabel = new Label(title);
productLabel.setFont(Font.font("Georgia", 16));
productLabel.setTextFill(Color.BROWN);
productItem.getChildren().addAll(productImage, productLabel);
// get triggers if you press on either picture or its name
productImage.setOnMouseClicked(e -> navigateToProduct(primaryStage, title, imagePath)); //method called
productLabel.setOnMouseClicked(e -> navigateToProduct(primaryStage, title, imagePath));
//productImage.setOnMouseClicked(e->navigateToProduct(primaryStage,"Flowers",imagePath) );
// productLabel.setOnMouseClicked(e->navigateToProduct(primaryStage,"Flowers",imagePath) );
return productItem;
}
private void showFlowerPage(Stage primaryStage, String title, String imagePath) {
VBox productPage = new VBox(20);
productPage.setAlignment(Pos.CENTER);
productPage.setPadding(new Insets(20));
productPage.setStyle("-fx-background-color: #f5f5dc;");
// Product Image
ImageView productImage = new ImageView(new Image(imagePath));
productImage.setFitWidth(300);
productImage.setFitHeight(300);
productImage.setPreserveRatio(true);
// Product Title
Text productTitle = new Text(title);
productTitle.setFont(Font.font("Book Antiqua", 28));
productTitle.setFill(Color.BROWN);
// Product Description
Label productDescription = new Label(getProductDescription(title));
productDescription.setWrapText(true);
productDescription.setFont(Font.font("Georgia", FontPosture.ITALIC, 14)); // Italic
productDescription.setTextFill(Color.BROWN);
productDescription.setMaxWidth(600);
productDescription.setAlignment(Pos.CENTER); // Center text
productDescription.setStyle("-fx-text-alignment: center;");
// Quantity Section
Label quantityLabel = new Label("Quantity");
quantityLabel.setFont(Font.font("Georgia", 18));
quantityLabel.setTextFill(Color.BROWN);
Button decreaseButton = new Button("-");
Label quantityValue = new Label("1");
quantityValue.setFont(Font.font("Georgia", 16));
quantityValue.setTextFill(Color.BROWN);
Button increaseButton = new Button("+");
HBox quantityBox = new HBox(10, decreaseButton, quantityValue, increaseButton);
quantityBox.setAlignment(Pos.CENTER);
quantityBox.setPadding(new Insets(10));
quantityBox.setStyle("-fx-border-color: #8B4513; -fx-border-width: 1px; -fx-border-radius: 5px;");
decreaseButton.setOnAction(e -> {
int qty = Integer.parseInt(quantityValue.getText());
if (qty > 1) quantityValue.setText(String.valueOf(qty - 1));
});
increaseButton.setOnAction(e -> {
int qty = Integer.parseInt(quantityValue.getText());
quantityValue.setText(String.valueOf(qty + 1));
});
// Color Options
Label colorLabel = new Label("Choose Color:");
colorLabel.setFont(Font.font("Times New Roman", 18));
colorLabel.setTextFill(Color.BROWN);
RadioButton red = new RadioButton("Red");
red.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
RadioButton pink = new RadioButton("Pink");
pink.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
RadioButton white = new RadioButton("White");
white.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
RadioButton blue = new RadioButton("Blue");
blue.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
RadioButton purple = new RadioButton("Purple");
purple.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
RadioButton multicolor = new RadioButton("Multicolor");
multicolor.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
ToggleGroup colorGroup = new ToggleGroup();
red.setToggleGroup(colorGroup);
pink.setToggleGroup(colorGroup);
white.setToggleGroup(colorGroup);
blue.setToggleGroup(colorGroup);
purple.setToggleGroup(colorGroup);
multicolor.setToggleGroup(colorGroup);
red.setSelected(true);
VBox colorBox = new VBox(10, colorLabel, red, pink, white, blue, purple, multicolor);
colorBox.setPadding(new Insets(10));
colorBox.setStyle("-fx-border-color: #8B4513; -fx-border-width: 1px; -fx-border-radius: 5px;");
// Note Section
CheckBox noteCheckbox = new CheckBox("Add a Note for Loved One (+50 Rs)");
noteCheckbox.setFont(Font.font("Times New Roman", 16));
noteCheckbox.setTextFill(Color.BROWN);
TextArea noteArea = new TextArea();
noteArea.setPromptText("Write your message here...");
noteArea.setDisable(true);
noteCheckbox.setOnAction(e -> noteArea.setDisable(!noteCheckbox.isSelected()));
VBox noteBox = new VBox(10, noteCheckbox, noteArea);
noteBox.setPadding(new Insets(10));
noteBox.setStyle("-fx-border-color: #8B4513; -fx-border-width: 1px; -fx-border-radius: 5px;");
// Buttons Section
Button addToCartButton = new Button("Add to Cart");
addToCartButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px 20px;");
addToCartButton.setOnAction(event -> {
int price = 500; // Base price for flowers
if (noteCheckbox.isSelected()) price += 50; // Add note cost
int quantity = Integer.parseInt(quantityValue.getText());
String color = ((RadioButton) colorGroup.getSelectedToggle()).getText();
String note = noteCheckbox.isSelected() ? noteArea.getText() : "";
String name = title + " - " + color;
com.example.demo6.Items item = new com.example.demo6.Items(name, price, quantity, note);
com.example.demo6.Items.list.add(item);
System.out.println("Added: " + item.getName() + ", Price: " + item.getPrice() + ", Quantity: " + item.getQuantity());
if (!note.isEmpty()) System.out.println("Note: " + note);
});
Button backButton = new Button("Back");
backButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px 20px;");
backButton.setOnAction(e -> navigateToSection(primaryStage, "Flowers"));
Button showCartButton = new Button("Show Cart");
showCartButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px 20px;");
showCartButton.setOnAction(event -> primaryStage.setScene(viewCart(primaryStage, new BorderPane())));
HBox buttonBox = new HBox(20, backButton, addToCartButton, showCartButton);
buttonBox.setAlignment(Pos.CENTER);
buttonBox.setPadding(new Insets(10));
// Add all elements to the page
productPage.getChildren().addAll(
productImage,
productTitle,
productDescription,
quantityBox,
colorBox,
noteBox,
buttonBox
);
// Add ScrollPane
ScrollPane scrollPane = new ScrollPane(productPage);
scrollPane.setFitToWidth(true);
scrollPane.setStyle("-fx-background-color: transparent;");
Scene productScene = new Scene(scrollPane, 800, 600);
primaryStage.setScene(productScene);
}
private void showBookPage(Stage primaryStage, String title, String imagePath) {
VBox productPage = new VBox(20);
productPage.setAlignment(Pos.CENTER);
productPage.setPadding(new Insets(20));
productPage.setStyle("-fx-background-color: #f5f5dc;");
// Product Image
ImageView productImage = new ImageView(new Image(imagePath));
productImage.setFitWidth(300);
productImage.setFitHeight(300);
productImage.setPreserveRatio(true);
// Product Title
Text productTitle = new Text(title);
productTitle.setFont(Font.font("Book Antiqua", 28));
productTitle.setFill(Color.BROWN);
// Product Description
Label productDescription = new Label(getProductDescription(title));
productDescription.setWrapText(true);
productDescription.setFont(Font.font("Georgia", FontPosture.ITALIC, 14)); // Italic
productDescription.setTextFill(Color.BROWN);
productDescription.setMaxWidth(600);
productDescription.setAlignment(Pos.CENTER); // Center text
productDescription.setStyle("-fx-text-alignment: center;");
// Radio Buttons for Borrow or Buy
Label optionLabel = new Label("Choose an Option:");
optionLabel.setFont(Font.font("Georgia", 18));
optionLabel.setTextFill(Color.BROWN);
RadioButton borrowButton = new RadioButton("Borrow (Free)");
borrowButton.setFont(Font.font("Georgia", 14));
borrowButton.setTextFill(Color.BROWN);
RadioButton buyButton = new RadioButton("Buy (350 Rs)");
buyButton.setFont(Font.font("Georgia", 14));
buyButton.setTextFill(Color.BROWN);
ToggleGroup optionGroup = new ToggleGroup();
borrowButton.setToggleGroup(optionGroup);
buyButton.setToggleGroup(optionGroup);
borrowButton.setSelected(true); // Default selection
VBox optionBox = new VBox(10, optionLabel, borrowButton, buyButton);
optionBox.setPadding(new Insets(10));
optionBox.setStyle("-fx-border-color: #8B4513; -fx-border-width: 1px; -fx-border-radius: 5px;");
// Buttons Section
Button addToCartButton = new Button("Add to Cart");
addToCartButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px 20px;");
addToCartButton.setOnAction(e -> {
int price = buyButton.isSelected() ? 350 : 0; // Buy costs 350 Rs, Borrow is free
String option = buyButton.isSelected() ? "Buy" : "Borrow";
String name = title + " - " + option;
com.example.demo6.Items item = new com.example.demo6.Items(name, price, 1);
com.example.demo6.Items.list.add(item);
System.out.println("Added: " + item.getName() + ", Price: " + item.getPrice());
});
Button backButton = new Button("Back");
backButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px 20px;");
backButton.setOnAction(e -> navigateToSection(primaryStage, "Books"));
Button showCartButton = new Button("Show Cart");
showCartButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px 20px;");
showCartButton.setOnAction(event -> primaryStage.setScene(viewCart(primaryStage, new BorderPane())));
HBox buttonBox = new HBox(20, backButton, addToCartButton, showCartButton);
buttonBox.setAlignment(Pos.CENTER);
buttonBox.setPadding(new Insets(10));
// Add all elements to the page
productPage.getChildren().addAll(
productImage,
productTitle,
productDescription,
optionBox,
buttonBox
);
// Add ScrollPane
ScrollPane scrollPane = new ScrollPane(productPage);
scrollPane.setFitToWidth(true);
scrollPane.setStyle("-fx-background-color: transparent;");
Scene productScene = new Scene(scrollPane, 800, 600);
primaryStage.setScene(productScene);
}
//for coffee descriptive page
private void showCoffeePage(Stage primaryStage, String title, String imagePath){
VBox productPage = new VBox(20);
productPage.setAlignment(Pos.CENTER);
productPage.setPadding(new Insets(20));
productPage.setStyle("-fx-background-color: #f5f5dc;");
// Product Image
ImageView productImage = new ImageView(new Image(imagePath)); //calling imageview and image class
productImage.setFitWidth(300);
productImage.setFitHeight(300);
productImage.setPreserveRatio(true);
// Product Title
Text productTitle = new Text(title);
productTitle.setFont(Font.font("Georgia", 28));
productTitle.setFill(Color.BROWN);
// Product Description
Label productDescription = new Label(getProductDescription(title));
productDescription.setWrapText(true);
productDescription.setFont(Font.font("Georgia", FontPosture.ITALIC, 14)); // Italic
productDescription.setTextFill(Color.BROWN);
productDescription.setMaxWidth(600);
productDescription.setAlignment(Pos.CENTER); // Center text
productDescription.setStyle("-fx-text-alignment: center;");
// Size Options
Label sizeLabel = new Label("Size");
sizeLabel.setFont(Font.font("Georgia", 18));
sizeLabel.setTextFill(Color.BROWN);
RadioButton smallSize = new RadioButton("Small");//choose only one
smallSize.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
RadioButton mediumSize = new RadioButton("Medium (+50 rs)");
mediumSize.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
RadioButton largeSize = new RadioButton("Large (+100 rs)");
largeSize.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
ToggleGroup sizeGroup = new ToggleGroup();
smallSize.setToggleGroup(sizeGroup);
mediumSize.setToggleGroup(sizeGroup);
largeSize.setToggleGroup(sizeGroup);
smallSize.setSelected(true);
VBox sizeBox = new VBox(10, sizeLabel, smallSize, mediumSize, largeSize);
sizeBox.setPadding(new Insets(10));
sizeBox.setStyle("-fx-border-color: #8B4513; -fx-border-width: 1px; -fx-border-radius: 5px;");
// Extras Options
Label extrasLabel = new Label("Extras");
extrasLabel.setFont(Font.font("Georgia", 18));
extrasLabel.setTextFill(Color.BROWN);
CheckBox whippedCream = new CheckBox("Whipped Cream"); //can choose more than one
whippedCream.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
CheckBox decafCoffee = new CheckBox("Decaf");
decafCoffee.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
CheckBox cinnamon = new CheckBox("Cinnamon");
cinnamon.setStyle("-fx-font-family: 'Georgia'; -fx-font-size: 12px; -fx-text-fill: #8B0000;");
VBox extrasBox = new VBox(10, extrasLabel, whippedCream, decafCoffee, cinnamon);
extrasBox.setPadding(new Insets(10));
extrasBox.setStyle("-fx-border-color: #8B4513; -fx-border-width: 1px; -fx-border-radius: 5px;");
// counts how many do you want
Label quantityLabel = new Label("Quantity");
quantityLabel.setFont(Font.font("Georgia", 18));
quantityLabel.setTextFill(Color.BROWN);
Button decreaseButton = new Button("-");
Label quantityValue = new Label("1");
quantityValue.setFont(Font.font("Georgia", 16));
quantityValue.setTextFill(Color.BROWN);
Button increaseButton = new Button("+");
HBox quantityBox = new HBox(10, decreaseButton, quantityValue, increaseButton);
quantityBox.setAlignment(Pos.CENTER);
quantityBox.setPadding(new Insets(10));
quantityBox.setStyle("-fx-border-color: #8B4513; -fx-border-width: 1px; -fx-border-radius: 5px;");
decreaseButton.setOnAction(e -> {
int currentQuantity = Integer.parseInt(quantityValue.getText()); //gets the quantity rn
if (currentQuantity > 1) { //make sure it doesnt go below 1
quantityValue.setText(String.valueOf(currentQuantity - 1)); //decreases
}
});
increaseButton.setOnAction(e -> {
int currentQuantity = Integer.parseInt(quantityValue.getText());
quantityValue.setText(String.valueOf(currentQuantity + 1)); //increases
});
// Buttons
Button addToCartButton = new Button("Add to Cart");
addToCartButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px 20px;");
addToCartButton.setOnAction(event -> {
int price = 650;
int quantity = Integer.parseInt(quantityValue.getText());
String size = "";
if (smallSize.isSelected()) {
size = smallSize.getText();
} else if (mediumSize.isSelected()) {
size = mediumSize.getText();
price += 50;
} else if (largeSize.isSelected()) {
size = largeSize.getText();
price += 100;
}
String name = productTitle.getText();
com.example.demo6.Items item = new com.example.demo6.Items(name, price, quantity);
com.example.demo6.Items.list.add(item);
System.out.println(item.getName());
System.out.println(item.getPrice());
System.out.println(item.getAmount());
System.out.println(item.getQuantity());
});
Button backButton = new Button("Back");
backButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px 20px;");
backButton.setOnAction(e -> navigateToSection(primaryStage, title));
Button ToCartButton = new Button("Show Cart");
ToCartButton.setStyle("-fx-background-color: #8B4513; -fx-text-fill: white; -fx-padding: 10px 20px;");
ToCartButton.setOnAction(event -> primaryStage.setScene(viewCart(primaryStage, new BorderPane())));
// Wrap buttons in an HBox for proper alignment
HBox buttonBox = new HBox(20, backButton, addToCartButton, ToCartButton);
buttonBox.setAlignment(Pos.CENTER);
buttonBox.setPadding(new Insets(10));
// Add components to the product page
productPage.getChildren().addAll(
productImage,
productTitle,
productDescription,
sizeBox,
extrasBox,
quantityBox,
buttonBox
);
// Scroll the product page
ScrollPane scrollPane = new ScrollPane(productPage);
scrollPane.setFitToWidth(true);
scrollPane.setStyle("-fx-background-color: transparent;");
Scene productScene = new Scene(scrollPane, 800, 600);
primaryStage.setScene(productScene);
}
//add on class
private void navigateToProduct(Stage primaryStage, String title, String imagePath) {//method defined
if (flowerNames.contains(title)) {
showFlowerPage(primaryStage, title, imagePath);
} else if (bookNames.contains(title)) {
showBookPage(primaryStage,title,imagePath);
} else {
showCoffeePage(primaryStage,title,imagePath);
}
}
private String getProductDescription(String title) {
switch (title) {
case "Machiato":
return "A delightful blend of rich espresso and a hint of velvety milk foam, perfectly balanced to create a bold yet smooth coffee experience.";
case "Cortado":
return "Espresso and milk in perfect balance neither eclipses the other. A drink for those who savor harmony.";
case "Flat White":
return "An espresso’s boldness wrapped in the satin whisper of micro-foamed milk.";
case "Americano":
return "Rich, smooth coffee made by diluting a shot of espresso with hot water, delivering a bold yet mellow flavor.";
case "Irish Coffee":
return "Espresso meets its match in the fiery embrace of Irish whiskey, softened by a cool crown of cream.";
case "Turkish Coffee":
return "Ground fine as dust and brewed to ancient perfection, this is a drink of bold tradition.";
case "Long Black":
return "Double espresso meets a splash of water, preserving its intensity.";
case "Mocha":
return "Rich chocolate combined with bold espresso and steamed milk, topped with a sweet whipped cream.";
case "Cold Brew":
return "Coffee’s darker mysteries revealed slow-steeped for hours, the essence of the bean emerges smooth and powerful.";
case "Cafe Macchiato":
return "A bold espresso crowned with a delicate dollop of steamed milk or foam, offering a harmonious blend of robust coffee and creamy smoothness. ";
case "Iced Americano":
return "Espresso dives into cold, crisp water over ice—a bold refreshment that’s as sharp as a breeze through city streets.";
case "Iced Mocha":
return "Rich chocolate and bold espresso chill together under a layer of frothy cream. It’s decadence on ice, perfect for indulgent days.";
case "Iced Latte":
return "Espresso and milk on ice—cool simplicity, where boldness meets a soothing chill. Each sip is a refreshing reset.";
case "Iced Vanilla Latte":
return "Bold espresso softened by silky milk and kissed with vanilla sweetness, served ice-cold. It’s the epitome of elegance and cool.";
case "Dalgona Iced Coffee":
return "Clouds of whipped coffee sit atop chilled milk, an airy contrast to the rich depth below. Sweet, creamy.";
case "Caramel Iced Latte":
return "A refreshing blend of rich espresso, creamy milk, and a drizzle of sweet caramel, served over ice.";
case "Salted Caramel":
return "Espresso and steamed milk mingle under a frothy crown, laced with salted caramel ribbons.";
case "Rose":
return "A timeless symbol of love and passion, the rose whispers stories of romance with every delicate petal.";
case "Tulip":
return "As gentle as spring’s first breeze, the tulip stands tall, carrying elegance and a promise of renewal.";
case "Daisy":
return "Bathed in innocence, the daisy blooms like a sunlit smile, bringing joy and purity to the heart.";
case "Carnation":
return "With petals soft as a lover's sigh, the carnation speaks of deep admiration, devotion, and enduring affection.";
case "Daffodils":
return "Golden trumpets of hope, daffodils herald the arrival of brighter days with their sunlit charm.";
case "Lily":
return "Graceful and serene, the lily rises like a quiet prayer, embodying purity, peace, and transcendence.";
case "Sunflower":
return "Turning always to the light, the sunflower radiates joy, a beacon of warmth, loyalty, and unshakable faith.";
case "It ends with us":
return "There is no such thing as bad people. We’re all just people who sometimes do bad things.";
case "Little Women":
return "I am not afraid of storms, for I am learning how to sail my ship.";
case "Harry Potter":
return "It is our choices, Harry, that show what we truly are, far more than our abilities.";
case "Pride and Prejudice":
return "I declare after all there is no enjoyment like reading!";
case "Emma":
return "Seldom, very seldom, does complete truth belong to any human disclosure.";
case "Milenal":
return "It's only because of their stupidity that they're able to be so sure of themselves.";
case "All the light we cannot see":
return "Open your eyes and see what you can with them before they close forever.";
case "Great Expectations":
return "Ask no questions, and you'll be told no lies.";
case "Bringing down the duke":
return "A woman should not have to wear a suit of armor to succeed in this world.";
default:
return "Delicious and satisfying coffee beverage.";
}
}
}