File tree Expand file tree Collapse file tree
java/org/launchcode/codingevents/models
resources/templates/events Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 */
88public class Event {
99
10+ private int id ;
11+ private static int nextId = 1 ;
12+
1013 private String name ;
1114 private String description ;
1215
1316 public Event (String name , String description ) {
1417 this .name = name ;
1518 this .description = description ;
19+ this .id = nextId ;
20+ nextId ++;
1621 }
1722
1823 public String getName () {
@@ -31,9 +36,25 @@ public void setDescription(String description) {
3136 this .description = description ;
3237 }
3338
39+ public int getId () {
40+ return id ;
41+ }
42+
3443 @ Override
3544 public String toString () {
3645 return name ;
3746 }
3847
48+ @ Override
49+ public boolean equals (Object o ) {
50+ if (this == o ) return true ;
51+ if (o == null || getClass () != o .getClass ()) return false ;
52+ Event event = (Event ) o ;
53+ return id == event .id ;
54+ }
55+
56+ @ Override
57+ public int hashCode () {
58+ return Objects .hash (id );
59+ }
3960}
Original file line number Diff line number Diff line change 88< table class ="table table-striped ">
99 < thead >
1010 < tr >
11+ < th > ID</ th >
1112 < th > Name</ th >
1213 < th > Description</ th >
1314 </ tr >
1415 </ thead >
1516 < tr th:each ="event : ${events} ">
17+ < td th:text ="${event.id} "> </ td >
1618 < td th:text ="${event.name} "> </ td >
1719 < td th:text ="${event.description} "> </ td >
1820 </ tr >
You can’t perform that action at this time.
0 commit comments