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 11package org .launchcode .codingevents .models ;
22
3+ import java .util .Objects ;
4+
35public class Event {
46
7+ private int id ;
8+ private static int nextId = 1 ;
59 private String name ;
610 private String description ;
711
812 public Event (String name , String description ) {
913 this .name = name ;
1014 this .description = description ;
15+ this .id = nextId ;
16+ nextId ++;
17+ }
18+
19+ public int getId () {
20+ return id ;
1121 }
1222
1323 public String getName () {
@@ -30,4 +40,17 @@ public void setDescription(String description) {
3040 public String toString () {
3141 return name ;
3242 }
43+
44+ @ Override
45+ public boolean equals (Object o ) {
46+ if (this == o ) return true ;
47+ if (o == null || getClass () != o .getClass ()) return false ;
48+ Event event = (Event ) o ;
49+ return id == event .id ;
50+ }
51+
52+ @ Override
53+ public int hashCode () {
54+ return Objects .hash (id );
55+ }
3356}
Original file line number Diff line number Diff line change 1212< table class ="table table-striped ">
1313 < thead >
1414 < tr >
15+ < th > ID</ th >
1516 < th > Name</ th >
1617 < th > Description</ th >
1718 </ tr >
1819 </ thead >
1920 < tr th:each ="event : ${events} ">
21+ < td th:text ="${event.id} "> </ td >
2022 < td th:text ="${event.name} "> </ td >
2123 < td th:text ="${event.description} "> </ td >
2224 </ tr >
You can’t perform that action at this time.
0 commit comments