File tree Expand file tree Collapse file tree
Spring Boot/codingevents/src/main
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 ;
9+
510 private String name ;
611 private String description ;
712
813 public Event (String name , String description ) {
914 this .name = name ;
1015 this .description = description ;
16+ this .id = nextId ;
17+ nextId ++;
1118 }
1219
1320 public String getName () {
@@ -26,8 +33,25 @@ public void setDescription(String description) {
2633 this .description = description ;
2734 }
2835
36+ public int getId () {
37+ return id ;
38+ }
39+
2940 @ Override
3041 public String toString () {
3142 return name ;
3243 }
44+
45+ @ Override
46+ public boolean equals (Object o ) {
47+ if (this == o ) return true ;
48+ if (o == null || getClass () != o .getClass ()) return false ;
49+ Event event = (Event ) o ;
50+ return id == event .id ;
51+ }
52+
53+ @ Override
54+ public int hashCode () {
55+ return Objects .hash (id );
56+ }
3357}
Original file line number Diff line number Diff line change @@ -10,11 +10,13 @@ <h1>All Events</h1>
1010< table class ="table table-striped ">
1111 < thead >
1212 < tr >
13+ < th > ID</ th >
1314 < th > Name</ th >
1415 < th > Description</ th >
1516 </ tr >
1617 </ thead >
1718 < tr th:each ="event : ${events} ">
19+ < td th:text ="${event.id} "> </ td >
1820 < td th:text ="${event.name} "> </ td >
1921 < td th:text ="${event.description} "> </ td >
2022 </ tr >
You can’t perform that action at this time.
0 commit comments