-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTicket.java
More file actions
104 lines (97 loc) · 3.25 KB
/
Ticket.java
File metadata and controls
104 lines (97 loc) · 3.25 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package prototype;
/**
* @author 1754025徐菡志
*/
public class Ticket extends TicketCloneable{
/**
* The constructor of Ticket Class.
* @param price:the price of ticket.
* @param date:the date of ticket that can be used.
* @param type: the type of ticket.
*/
public Ticket(double price,String date,String type){
this.price=price;
this.date=date;
this.type=type;
if(this.giftticket!=null){
System.out.println(getClass().getSimpleName() +
":(" +
this.hashCode()+
"):Ticket():create ticket" +
"{" +
"price=" + price +
", date='" + date + '\'' +
", type='" + type + '\'' +
", giftticket.hashcode=" +
this.giftticket.hashCode() +
"} successfully.");
}
else{
System.out.println(getClass().getSimpleName() +
":(" +
this.hashCode()+
"):Ticket():create ticket" +
"{" +
"price=" + price +
", date='" + date + '\'' +
", type='" + type + '\'' +
"} successfully.");
}
}
/**
* @return formatted ticket information.
*/
public String getFormattedInfo() {
if(this.giftticket!=null){
return
getClass().getSimpleName()+
":(" +
this.hashCode()+
"):getFormattedInfo():ticket"+
"{" +
"price=" + price +
", date='" + date + '\'' +
", type='" + type + '\'' +
", giftticket.hashcode=" +
this.giftticket.hashCode()+
"}.";
}
else{
return
getClass().getSimpleName()+
" " +
this.hashCode()+
": getFormattedInfo():ticket"+
"{" +
"price=" + price +
", date='" + date + '\'' +
", type='" + type + '\'' +
"}.";
}
}
/**
* @return the basic information of ticket.
*/
public String getInfo() {
if(this.giftticket!=null){
return
"ticket"+
"{" +
"price=" + price +
", date='" + date + '\'' +
", type='" + type + '\'' +
", giftticket.hashcode=" +
this.giftticket.hashCode()+
"}.";
}
else{
return
"ticket"+
": {" +
"price=" + price +
", date='" + date + '\'' +
", type='" + type + '\'' +
"}.";
}
}
}