-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEvent.java
More file actions
74 lines (64 loc) · 1.63 KB
/
Copy pathEvent.java
File metadata and controls
74 lines (64 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* A class which contains the events of the sports.
*/
public class Event implements Comparable<Event>
{
private String eventName;
private int numberOfTicketLeft;
public Event(String eventName, int numberOfTicketLeft)
{
this.eventName = eventName;
this.numberOfTicketLeft = numberOfTicketLeft;
}
public Event(String eventName)
{
this.eventName = eventName;
}
public String getEventName()
{
return eventName;
}
public void setEventName(String eventName)
{
this.eventName = eventName;
}
public int getNumberOfTicketLeft()
{
return numberOfTicketLeft;
}
public void setNumberOfTicketLeft(int numberOfTicketLeft)
{
this.numberOfTicketLeft = numberOfTicketLeft;
}
/**
* compare the name of the events
* @param e
* @return the int type after the comparision, which is <0, =0 and >0
*/
public int compareTo(Event e)
{
int names = eventName.compareTo(e.eventName);
return names;
}
/**
* Override the toString method
* @return the event name and the tickets left
*/
public String toString()
{
return ("The event name is: " + eventName + "," + " with " + numberOfTicketLeft + " tickets left!\n");
}
/**
* Override the equals method
* @param obj
* @return type boolean, if the event name is the same, return true, vise versa
*/
public boolean equals(Object obj)
{
if (this.eventName.equals(((Event)obj).getEventName()))
{
return true;
}
return false;
}
}