-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTicketFinder.java
More file actions
38 lines (35 loc) · 1.11 KB
/
TicketFinder.java
File metadata and controls
38 lines (35 loc) · 1.11 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
package nullobject;
import java.util.ArrayList;
/**
* @author 1851594王思桐
*/
public class TicketFinder {
/**
* Emulate a Ticket Database
*/
private ArrayList<Ticket> TicketDataBase = new ArrayList<Ticket>();
/**
* Add three default Tickets into DataBase
*/
public TicketFinder(){
TicketDataBase.add(new ValidTicket("0001","0001","adult"));
TicketDataBase.add(new ValidTicket("0002","0002","adult"));
TicketDataBase.add(new ValidTicket("0003","0003","adult"));
}
/**
* Find Ticket in DataBase with a Stub
* @param s:Stub the stub belongs to customer
* @return ValidTicket if there is a corresponding ticket in database
* NullTicket if not.
*/
public Ticket Find(Stub s){
for(int i = 0;i< TicketDataBase.size();i++){
boolean a = TicketDataBase.get(i).getID().equals(s.getID());
boolean b = TicketDataBase.get(i).getCustomerID().equals(s.getCustomerID());
if(a && b){
return TicketDataBase.get(i);
}
}
return new NullTicket();
}
}