11package org .launchcode .codingevents .models ;
22
3+ import jakarta .validation .constraints .*;
4+
5+ import java .time .LocalDate ;
36import java .util .Objects ;
47
58/**
@@ -10,16 +13,45 @@ public class Event {
1013 private int id ;
1114 private static int nextId = 1 ;
1215
16+ @ NotBlank (message = "Name is required." )
17+ @ Size (min = 3 , max = 50 , message = "Name must be between 3 and 50 characters" )
1318 private String name ;
19+
20+ @ Size (max = 500 , message = "Description too long!" )
1421 private String description ;
1522
16- public Event (String name , String description ) {
23+ @ NotBlank (message = "Email is required." )
24+ @ Email (message = "Invalid email. Try again." )
25+ private String contactEmail ;
26+
27+ // Chapter Exercise Code Added
28+ @ NotBlank (message = "Location is required." )
29+ @ NotNull
30+ private String location ;
31+
32+ @ AssertTrue (message = "Registration must be marked 'True'." )
33+ private Boolean registrationRequired = true ;
34+
35+ @ Positive (message = "Attendees must be greater than 0." )
36+ private int numberOfAttendees ;
37+
38+ @ Future (message = "Event must have a future date." )
39+ private LocalDate eventDate ;
40+
41+ public Event (String name , String description , String contactEmail ,
42+ String location , int numberOfAttendees , LocalDate eventDate ) {
1743 this .name = name ;
1844 this .description = description ;
45+ this .contactEmail = contactEmail ;
46+ this .location = location ;
47+ this .numberOfAttendees = numberOfAttendees ;
48+ this .eventDate = eventDate ;
1949 this .id = nextId ;
2050 nextId ++;
2151 }
2252
53+ public Event (){}
54+
2355 public String getName () {
2456 return name ;
2557 }
@@ -36,10 +68,50 @@ public void setDescription(String description) {
3668 this .description = description ;
3769 }
3870
71+ public String getContactEmail () {
72+ return contactEmail ;
73+ }
74+
75+ public void setContactEmail (String contactEmail ) {
76+ this .contactEmail = contactEmail ;
77+ }
78+
79+ public String getLocation () {
80+ return location ;
81+ }
82+
83+ public void setLocation (String location ) {
84+ this .location = location ;
85+ }
86+
3987 public int getId () {
4088 return id ;
4189 }
4290
91+ public Boolean getRegistrationRequired () {
92+ return registrationRequired ;
93+ }
94+
95+ public void setRegistrationRequired (Boolean registrationRequired ) {
96+ this .registrationRequired = registrationRequired ;
97+ }
98+
99+ public int getNumberOfAttendees () {
100+ return numberOfAttendees ;
101+ }
102+
103+ public void setNumberOfAttendees (int numberOfAttendees ) {
104+ this .numberOfAttendees = numberOfAttendees ;
105+ }
106+
107+ public LocalDate getEventDate () {
108+ return eventDate ;
109+ }
110+
111+ public void setEventDate (LocalDate eventDate ) {
112+ this .eventDate = eventDate ;
113+ }
114+
43115 @ Override
44116 public String toString () {
45117 return name ;
0 commit comments