aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/Event.java
diff options
context:
space:
mode:
authorYuuta Liang <yuutaw@student.cs.ubc.ca>2023-11-28 11:33:45 -0800
committerYuuta Liang <yuutaw@student.cs.ubc.ca>2023-11-28 11:33:45 -0800
commitca46721f155da0e0fd4d772cdbe4d590cc2f6913 (patch)
treedfd3f87ee2bbf882c280ad9d998f4cbfa092bce4 /src/main/model/Event.java
parent096b6866408da72db37051565f8b5b450df920d7 (diff)
downloadjca-ca46721f155da0e0fd4d772cdbe4d590cc2f6913.tar
jca-ca46721f155da0e0fd4d772cdbe4d590cc2f6913.tar.gz
jca-ca46721f155da0e0fd4d772cdbe4d590cc2f6913.tar.bz2
jca-ca46721f155da0e0fd4d772cdbe4d590cc2f6913.zip
Import Event / EventLog
Signed-off-by: Yuuta Liang <yuutaw@student.cs.ubc.ca>
Diffstat (limited to 'src/main/model/Event.java')
-rw-r--r--src/main/model/Event.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/main/model/Event.java b/src/main/model/Event.java
new file mode 100644
index 0000000..c6a4993
--- /dev/null
+++ b/src/main/model/Event.java
@@ -0,0 +1,66 @@
+package model;
+
+import java.util.Calendar;
+import java.util.Date;
+
+
+/**
+ * Represents an alarm system event.
+ */
+public class Event {
+ private static final int HASH_CONSTANT = 13;
+ private Date dateLogged;
+ private String description;
+
+ /**
+ * Creates an event with the given description
+ * and the current date/time stamp.
+ * @param description a description of the event
+ */
+ public Event(String description) {
+ dateLogged = Calendar.getInstance().getTime();
+ this.description = description;
+ }
+
+ /**
+ * Gets the date of this event (includes time).
+ * @return the date of the event
+ */
+ public Date getDate() {
+ return dateLogged;
+ }
+
+ /**
+ * Gets the description of this event.
+ * @return the description of the event
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+
+ if (other.getClass() != this.getClass()) {
+ return false;
+ }
+
+ Event otherEvent = (Event) other;
+
+ return (this.dateLogged.equals(otherEvent.dateLogged)
+ && this.description.equals(otherEvent.description));
+ }
+
+ @Override
+ public int hashCode() {
+ return (HASH_CONSTANT * dateLogged.hashCode() + description.hashCode());
+ }
+
+ @Override
+ public String toString() {
+ return dateLogged.toString() + "\n" + description;
+ }
+}