-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.java
2067 lines (1865 loc) · 75.7 KB
/
Source.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
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
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* This is a school project for the Object-Oriented Programming (OOP) course at Umm Al-Qura University (UQU).
* The program consists of a collection of classes designed to improve users' salon experience through a beauty salon UI.
* Our program's primary goal is to streamline salon reservations.
* Users can select desired services, update reservation details (such as time or date),
* choose a stylist within their budget, view stylist and service information, generate reservation receipts,
* apply discounts if desired (discarded due to time constraints), and finally, cancel the reservation.
*
* Created by Maisa Alzahrani and Aseel Keleeb on January 12, 2023.
* Students at Umm Al-Qura University (UQU) majoring in Computer Science.
* This project was completed under the supervision of Dr. Bushra Al-Gotiml on February 16, 2023.
* Copyright © 2023 Maisa Alzahrani and Aseel Keleeb. All rights reserved.
*
* @author Maisa Alzahrani, Aseel Keleeb
*/
/**
* These are the import statements for the beauty salon reservation system.
* The imported classes and packages provide necessary functionality and dependencies.
*
* Imported Packages:
* {@code java.util}: Provides utility classes and data structures for general-purpose use.
* {@code java.time.LocalTime}: Represents a time of day without a date or time zone.
* {@code java.time.LocalDate}: Represents a date without a time or time zone.
*/
import java.util.*;
import java.time.LocalTime;
import java.time.LocalDate;
/**
* The Time class represents time-related functionalities for managing reservation and receipt times.
* It provides methods to set and retrieve hours, minutes, and seconds for reservations and receipts.
* Users can create instances to handle time-specific operations within the salon booking system.
*/
class Time {
/**
* Attributes for representing the second, minute, and hour components of time.
* These attributes are used to store and retrieve the respective components of reservation and receipt times.
*/
private int second, minute, hours;
/**
* Default constructor for Time.
*/
public Time() {}
/**
* Constructor to set the reservation time, ensuring it falls within working hours.
* @param hours The hour of the reservation (10-22).
* @param minute The minute of the reservation (0-59).
*/
public Time(int hours, int minute) {
if(hours>=10&&hours<=22&&minute<=60&&minute>=0){
this.minute = minute;
this.hours = hours;}
else{
System.err.println("Out of work time!");}
}
/**
* Constructor to create an object for receipt time.
* @param hours The hour of the receipt.
* @param minute The minute of the receipt.
* @param second The second of the receipt.
*/
public Time(int hours, int minute, int second) {
this.second = second;
this.minute = minute;
this.hours = hours;
}
//setters & getters
/**
* Getter for seconds.
* @return The seconds of the time.
*/
public int getSecond() {
return second;
}
/**
* Setter for seconds.
* @param second The seconds to set.
*/
public void setSecond(int second) {
this.second = second;
}
/**
* Getter for minutes.
* @return The minutes of the time.
*/
public int getMinute() {
return minute;
}
/**
* Setter for minutes.
* Ensures that the input minute is within the range of 0 to 59 (inclusive).
* @param minute The minute to set.
*/
public void setMinute(int minute) {
if(minute<=60&&minute>=0)
this.minute = minute;
}
/**
* Getter for hours.
* @return The hours of the time.
*/
public int getHours() {
return hours;
}
/**
* Setter for hours.
* Ensures that the input hour is within the range of 10 to 22 (inclusive).
* @param hours The hour to set.
*/
public void setHours(int hours) {
if(hours<=10&&hours>=22)
this.hours = hours;
}
/**
* Checks if the time falls within the specified work hours (10:00 - 22:00).
* @return true if the time is within work hours, false otherwise.
*/
public boolean check(){
if(hours>=10&&hours<=22&&minute<=60&&minute>=0){
return true;}
else{
return false;}
}
/**
* Overrides the equals method to compare Time objects.
* @param obj The object to compare. Must be an instance of the {@code Time} class.
* @return true if the objects are equal, false otherwise.
*/
@Override
public boolean equals(Object obj){
Time t=(Time)obj;
if (t.hours==this.hours && t.minute==this.minute)
return true;
else
return false;
}
/**
* Generates a string representation of the time.
* @return The string representation of the time (HH:MM:SS).
*/
@Override
public String toString() {
return "{" + hours + ":" + minute + ":" + second + '}';
}
}//Time class
/**
* The Date class manages date-related functionalities for handling reservation and receipt dates.
* It allows setting and retrieving year, month, and day components for reservations and receipts.
* Instances of this class assist in managing date-specific operations within the salon booking system.
*/
class Date {
/**
* Attributes for representing the year, month, and day components of a date.
* These attributes are used to store and retrieve the respective components of reservation and receipt dates.
*/
private int year;
private int month;
private int day;
/**
* Default constructor for Date initializing attributes to zero.
*/
public Date(){
year=day=month=0;
}
/**
* Constructor to set the reservation date, ensuring the input date is valid.
* @param day The day of the reservation (1-31).
* @param month The month of the reservation (1-12).
* @param year The year of the reservation (2023 or later).
*/
public Date(int day,int month,int year){
if(year>=2023&&month<=12&&month>=1&&day<=31&&day>=1){
this.day=day;
this.month=month;
this.year=year;}
else{
System.err.println("The date you entered is not correct! Please try again.");
}
}
//setters & getters
/**
* Getter for the year.
* @return The year of the date.
*/
public int getYear() {
return year;
}
/**
* Setter for the year.
* @param year The year to set.
* The year must be equal to or greater than 2023 to be considered valid.
*/
public void setYear(int year) {
if(year>=2023){
this.year = year; }
}
/**
* Getter for the month.
* @return The month of the date.
*/
public int getMonth() {
return month;
}
/**
* Setter for the month.
* @param month The month to set.
* The month must be between 1 and 12 (inclusive) to be considered valid.
*/
public void setMonth(int month) {
if(month<=12&&month>=1){
this.month = month;}
}
/**
* Getter for the day.
* @return The day of the date.
*/
public int getDay() {
return day;
}
/**
* Setter for the day.
* @param day The day to set.
* The day must be between 1 and 31 (inclusive) to be considered valid.
*/
public void setDay(int day) {
if(day<=31&&day>=1)
this.day = day;
}
/**
* Checks if the date falls within the specified valid range.
* @return true if the date is within the valid range, otherwise false.
*/
public boolean check(){
if(year>=2023&&month<=12&&month>=1&&day<=31&&day>=1){
return true;}
else{
return false;}
}
/**
* Generates a string representation of the date.
* @return The string representation of the date (DD/MM/YYYY).
*/
@Override
public String toString(){
return day+"/"+month+"/"+year ;
}
/**
* Overrides the equals method to compare Date objects.
* @param obj The object to compare. Must be an instance of the Date class.
* @return true if the objects are equal, otherwise false.
*/
@Override
public boolean equals(Object obj){
Date d=(Date)obj;
if (d.day==this.day && d.month==this.month && d.year==this.year)
return true;
else
return false;
}
}//Date class
/**
* The Person class serves as the superclass for both Stylist and Customer classes.
* It defines attributes and methods related to individuals (customers or stylists) in the salon system.
*/
class Person {
/**
* Attributes used to identify the name and phone number of the person (customer or stylist).
*/
private String name;
private String phoneNumber="";
/**
* Default constructor for Person.
*/
public Person() {}
/**
* Constructor to set the name and phone number of the person.
* @param name The name of the person.
* @param phoneNumber The phone number of the person. Must be a 10-digit number.
*/
public Person(String name, String phoneNumber) {
this.name = name;
// Validates and sets the phone number.
if(phoneNumber.length()==10){
this.phoneNumber = phoneNumber;
}else{System.err.println("invalid phone Number :(");}
}
//setters & getters
/**
* Getter for the name.
* @return The name of the person.
*/
public String getName() {
return name;
}
/**
* Setter for the name.
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* Getter for the phone number.
* @return The phone number of the person.
*/
public String getPhoneNumber() {
return phoneNumber;
}
/**
* Setter for the phone number.
* @param phoneNumber The phone number to set. Must be a 10-digit number.
*/
public void setPhoneNumber(String phoneNumber) {
if(phoneNumber.length()==10){
this.phoneNumber = phoneNumber;
}else{System.err.println("invalid phone Number :(");}
}
/**
* Generates a string representation of the person's name and phone number.
* @return String representation of the person.
*/
@Override
public String toString() {
return "Name: " + name + "\nPhone Number: " + phoneNumber;
}
/**
* Overrides the equals method to compare Person objects by name and phone number.
* @param obj The object to compare. Should be an instance of the Person class.
* @return True if the objects are equal (matching name and phone number), otherwise false.
*/
@Override
public boolean equals(Object obj) {
Person c =(Person)obj;
if (c.getName().equalsIgnoreCase(this.name)&&c.getPhoneNumber().equals(this.phoneNumber)){
return true;
} else {
return false;
}
}
}//Person class
/**
* The Customer class represents information specific to customers.
* It extends the Person class and adds attributes related to customer details.
*/
class Customer extends Person {
/**
* Attribute used to identify the Credit Card Number of the customer.
*/
private String CreditCardNo;
/**
* Default constructor for Customer.
*/
public Customer() {}
/**
* Constructor to set the name, phone number, and credit card number of the customer.
* @param name The name of the customer.
* @param phoneNumber The phone number of the customer.
* @param CreditCardNo The credit card number of the customer. Must be a 16-digit number.
*/
public Customer(String name, String phoneNumber, String CreditCardNo) {
super(name,phoneNumber);
// Validates and sets the credit card number.
if(CreditCardNo.length()==16){
this.CreditCardNo= CreditCardNo;
}else{System.err.println("Invalid Credit Card Number :(");}
}
//setters and getters
/**
* Getter for the Credit Card Number, masking most of the digits for privacy and security.
* @return String representation of masked Credit Card Number.
*/
public String getCreditCardNo() {
String creditCard="**** **** **** "+CreditCardNo.substring(12);
return creditCard;
}
/**
* Setter for the Credit Card Number.
* @param CreditCardNo The credit card number to set. Must be a 16-digit number.
*/
public void setCreditCardNo(String CreditCardNo) {
if(CreditCardNo.length()==16){
this.CreditCardNo= CreditCardNo;
}else{System.err.println("Invalid Credit Card Number :(");}
}
/**
* Overrides the toString method to display customer information.
* @return String representation of customer's name and phone number.
*/
@Override
public String toString() {
return super.toString();
}
}//Customer class
/**
* The Stylist class holds information specific to stylists.
* It extends the Person class and includes attributes related to stylist details.
*/
class Stylist extends Person {
/**
* Attribute used to identify the stylist.
*/
private String id;
/**
* Attribute used to define the job of the stylist.
*/
private Service job;
/**
* Default constructor for Stylist.
*/
public Stylist() {}
/**
* Constructor to set the name, phone number, stylist ID, and job of the stylist.
* @param name The name of the stylist.
* @param phoneNumber The phone number of the stylist.
* @param id The ID of the stylist.
* @param job The job (service) assigned to the stylist.
*/
public Stylist(String name,String phoneNumber,String id,Service job){
super(name,phoneNumber);
this.id = id;
this.job = job;
}
//setters & getters
/**
* Getter for the stylist's ID.
* @return String representing the stylist's ID.
*/
public String getId() {
return id;
}
/**
* Setter for the stylist's ID.
* @param id The ID to set for the stylist.
*/
public void setId(String id) {
this.id = id;
}
/**
* Getter for the job (service) assigned to the stylist.
* @return Service representing the stylist's job.
*/
public Service getJob() {
return job;
}
/**
* Setter for the job (service) assigned to the stylist.
* @param job The job (service) to set for the stylist.
*/
public void setJob(Service job) {
this.job = job;
}
/**
* Overrides the toString method to display stylist information.
* @return String representation of stylist's name, phone number, and ID.
*/
@Override
public String toString() {
return "Name: " + super.getName() + "\nPhone Number: " + super.getPhoneNumber()+"\nID: " + id ;
}
}//Stylist class
/**
* The BookingManagement interface declares a method for calculating the price of each service.
* Implementing classes will define the logic for calculating service prices within the booking system.
*/
interface BookingManagement {
/**
* Calculates the price for each service.
* Implementing classes will provide specific implementations for this method.
*/
void calculatePrice();
}//BookingManagement interface
/**
* The Service class represents various services provided to customers.
* It defines attributes and methods related to customer services within the salon booking system.
* This class is abstract and implements the BookingManagement interface to calculate service prices.
* Subclasses will provide specific implementations for different service types.
*/
abstract class Service implements BookingManagement {
/**
* Attributes used to describe details of the customer's service.
* These attributes are used to store and retrieve the price, date, time and stylist assigned to the service.
*/
private double price;
private Date date;
private Time time;
private Stylist stylist=new Stylist();
//Maisa added this one
/**
* The customer for whom the service is scheduled.
* We added this attribute to make the service to the customer
*/
private Customer customer;
/**
* Default constructor for the Service class.
*/
public Service(){}
/**
* Constructor to set the date and time for the service.
* @param date The date of the service.
* @param time The time of the service.
*/
public Service(Date date,Time time){
this.date=date;
this.time=time;
}
/**
* Constructor to set the date, time, and stylist for the service.
* @param date The date of the service.
* @param time The time of the service.
* @param stylist The stylist for the service.
*/
public Service(Date date,Time time,Stylist stylist){
this.date=date;
this.time=time;
this.stylist=stylist;
}
//Maisa added this one
/**
* Constructor to set the price, date, time, and customer for the service.
* @param price The price of the service.
* @param date The date of the service.
* @param time The time of the service.
* @param customer The customer for the service.
*/
public Service(double price, Date date, Time time, Customer customer) {
this.price = price;
this.date = date;
this.time = time;
this.customer = customer;
}
//setters & getters
/**
* Getter for the stylist assigned to the service.
* @return The Stylist object associated with the service.
*/
public Stylist getStylist() {
return stylist;
}
/**
* Setter for the stylist assigned to the service.
* @param stylist The Stylist object to assign to the service.
*/
public void setStylist(Stylist stylist) {
this.stylist = stylist;
}
/**
* Getter for the date of the service.
* @return The Date object representing the date of the service.
*/
public Date getDate() {
return date;
}
/**
* Setter for the date of the service.
* @param date The Date object to set for the service.
*/
public void setDate(Date date) {
this.date = date;
}
/**
* Getter for the time of the service.
* @return The Time object representing the time of the service.
*/
public Time getTime() {
return time;
}
/**
* Setter for the time of the service.
* @param time The Time object to set for the service.
*/
public void setTime(Time time) {
this.time = time;
}
/**
* Getter for the price of the service.
* @return The price of the service.
*/
public double getPrice(){
return price;
}
/**
* Setter for the price of the service.
* @param price The price to set for the service.
*/
public void setPrice(double price){
this.price=price;
}
/**
* Getter for the customer for whom the service is scheduled.
* @return The Customer object associated with the service.
*/
public Customer getCustomer() {
return customer;
}
/**
* Setter for the customer for whom the service is scheduled.
* @param customer The Customer object associated with the service.
*/
public void setCustomer(Customer customer) {
this.customer = customer;
}
/**
* Calculates the price for the service.
* Implementing classes will provide specific implementations for this method.
*/
@Override
public abstract void calculatePrice();
/**
* Returns a string representation of the service attributes.
* @return A string representation of the service.
*/
@Override
public String toString() {
return "Service:\nStylist: " + stylist +"\nPrice: "+getPrice();
}
/**
* Checks if the service is equal to another object.
* @param obj The object to compare. Must be an instance of Service.
* @return True if the service is equal to the object, false otherwise.
*/
@Override
public boolean equals(Object obj) {
Service s=(Service)obj;
if (s.date.equals(this.date)&&s.time.equals(this.time)&&s.stylist.equals(this.stylist)){
return true;
} else {
return false;
}
}
}//Service class
/**
* The Nails class represents nail-related services offered by the salon.
* It extends the Service class and includes specific attributes and methods for nail services.
* This class provides functionalities to set nail shape, polish color, and determine if a pedicure is included.
*/
class Nails extends Service {
/**
* Attributes used to describe the details of a customer's nail service.
* These attributes include the shape of the nails, the color of the nail polish,
* and a flag indicating if a pedicure is included.
*/
private String Shape,polishColor;
private boolean pedicure;
// Constructors
/**
* Default constructor for Nails services.
*/
public Nails() {}
/**
* Constructor for creating a Nails service with the specified nail shape and polish color.
* @param shape The shape of the nails.
* @param polishColor The color of the nail polish.
*/
public Nails(String shape,String polishColor){
this.polishColor= polishColor;
this.Shape= shape;
}
/**
* Constructor for creating a Nails service with the specified date, time, stylist, nail shape, and polish color.
* @param date The date for the appointment.
* @param time The time for the appointment.
* @param stylist The stylist assigned to the appointment.
* @param shape The shape of the nails.
* @param polishColor The color of the nail polish.
*/
public Nails(Date date,Time time,Stylist stylist,String shape,String polishColor){
super(date,time,stylist);
this.polishColor= polishColor;
this.Shape= shape;
}
// setters and getters
/**
* Getter for the pedicure inclusion flag.
* @return True if a pedicure is included, false otherwise.
*/
public boolean getPedicure() {
return pedicure;
}
/**
* Setter for the pedicure inclusion flag.
* @param pedicure True to include a pedicure, false otherwise.
*/
public void setPedicure(boolean pedicure) {
this.pedicure = pedicure;
}
/**
* Getter for nail shape.
* @return The shape of the nails.
*/
public String getShape() {
return Shape;
}
/**
* Setter for nail shape.
* @param shape The shape of the nails to set.
*/
public void setShape(String shape) {
this.Shape = shape;
}
/**
* Getter for the nail polish color.
* @return The polish color of the nails.
*/
public String getPolishColor() {
return polishColor;
}
/**
* Setter for the nail polish color.
* @param polishColor The polish color to set for the nails.
*/
public void setPolishColor(String polishColor) {
this.polishColor = polishColor;
}
/**
* Calculates the price for the nails service based on the included features.
* Overrides the calculatePrice method from the parent class.
* The price is determined by setting a base price and adding an additional fee if a pedicure is included.
*/
@Override
public void calculatePrice() {
super.setPrice(20);
if(pedicure){
super.setPrice(getPrice()+50);
}else{
super.setPrice(getPrice());
}
}
/**
* Provides a string representation of the Nails service.
* Overrides the toString method from the parent class.
* @return A string representation of the Nails service, including the nail shape, polish color, and price.
*/
@Override
public String toString() {
return "Nails Service\nShape: " + Shape + "\nPolish Color: " + polishColor+"\nPrice: "+getPrice();
}
}//Nails class
/**
* The Face class represents face-related services offered by the salon.
* It extends the Service class and includes specific attributes and methods for face services.
* This class provides functionalities to set makeup type, makeup color, and determine if skincare is included.
*/
class Face extends Service {
/**
* Attributes used to describe the details of a customer's face service.
* These attributes include the type of makeup, the color of the makeup,
* and a flag indicating if skincare is included.
*
* The makeupType attribute should be one of the following:
* 1 for special occasions, 2 for normal/everyday makeup, 3 for bridal makeup.
*/
private String makeupColor;
private int makeupType;
private boolean skinCare;
//Constructors
/**
* Default constructor for Face services.
*/
public Face(){}
/**
* Constructor for creating a Face service with the specified makeup type and makeup color.
* @param makeupType The type of makeup (1 for special, 2 for normal, 3 for bridal).
* @param makeupColor The color of the makeup.
*/
public Face(int makeupType, String makeupColor) {
this.makeupType = makeupType;
this.makeupColor = makeupColor;
}
/**
* Constructor for creating a Face service with the specified date, time, stylist, makeup type, and makeup color.
* @param date The date for the appointment.
* @param time The time for the appointment.
* @param stylist The stylist assigned to the appointment.
* @param makeupType The type of makeup (1 for special, 2 for normal, 3 for bridal).
* @param makeupColor The color of the makeup.
*/
public Face(Date date,Time time,Stylist stylist,int makeupType, String makeupColor) {
super(date,time,stylist);
this.makeupType = makeupType;
this.makeupColor = makeupColor;
}
//setters and getters
/**
* Getter for skincare inclusion.
* @return True if skincare is included, false otherwise.
*/
public boolean isSkinCare() {
return skinCare;
}
/**
* Setter for skincare inclusion.
* @param skinCare True to include skincare, false otherwise.
*/
public void setSkinCare(boolean skinCare) {
this.skinCare = skinCare;
}
/**
* Getter for makeup type.
* @return The type of makeup (1 for special, 2 for normal, 3 for bridal).
*/
public int getMakeupType() {
return makeupType;
}
/**
* Setter for makeup type.
* A switch-case statement is used to set the price for each makeup type.
* @param makeupType The type of makeup to set (1 for special, 2 for normal, 3 for bridal).
*/
public void setMakeupType(int makeupType) {
switch(makeupType){
case 1:// special occasions
super.setPrice(200);
break;
case 2:// normal/everyday makeup
super.setPrice(150);
break;
case 3:// bridal makeup
super.setPrice(300);
break;
default:// neither
System.out.println("Invalid input!!");
}
}
/**
* Getter for makeup color.
* @return The color of the makeup.
*/
public String getMakeupColor() {
return makeupColor;
}
/**
* Setter for makeup color.
* @param makeupColor The color of the makeup to set.
*/
public void setMakeupColor(String makeupColor) {
this.makeupColor = makeupColor;
}
/**
* Calculates the price for the Face service based on included features.
* Overrides the calculatePrice method from the parent class.
* The price is determined by setting a base price for each makeup type and
* adding an additional fee if skincare is included.
*/
@Override
public void calculatePrice() {
if(skinCare){
super.setPrice(getPrice()+50);
}else{
super.setPrice(getPrice());
}
}
/**
* Provides a string representation of the Face service.
* Overrides the toString method from the parent class.
* @return A string representation of the Face service details, including the makeup type, makeup color,
* skincare inclusion, and price.
*/
@Override
public String toString() {
String t=new String();
if (makeupType==1)
t="Special";
else if (makeupType==2)
t="Normal";
else
t="Bridal";
return "Face Service\nMakeup Type: " + t + "\nMakeup Color: " + makeupColor+"\nSkincare: "+skinCare+"\nPrice: "+getPrice();
}
}//Face class
/**
* The Hair class represents hair-related services offered by the salon.
* It extends the Service class and includes specific attributes and methods for hair services.
* This class provides functionalities to set hairstyle type, length, and calculate prices accordingly.
*/
class Hair extends Service{
/**
* Attributes used to describe the details of a hair service.
* These attributes include the hairstyle type and the length of the hair.
*
* The style attribute should be one of the following:
* 1 for special hairstyle, 2 for normal hairstyle, 3 for haircut and dye.
*
* The length attribute should be one of the following:
* 1 for short hair, 2 for mid-length hair, 3 for long hair.
*/
private int length,style;
//Constructors
/**
* Default constructor for Hair services.
*/
public Hair(){}
/**
* Constructor for Hair services with date, time, stylist, and hairstyle type.
* @param date The date for the appointment.
* @param time The time for the appointment.
* @param stylist The stylist assigned to the appointment.
* @param style The type of hairstyle (1 for special, 2 for normal, 3 for cut and dye).
*/
public Hair( Date date, Time time, Stylist stylist,int style) {
super(date, time, stylist);
this.style = style;
}