-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConcert.java
80 lines (73 loc) · 2.49 KB
/
Concert.java
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
/**
* Handles concert tickets
*/
public class Concert extends Ticket {
// Stores if the ticket is for standing
private boolean standing;
// Stores if the ticket includes backstage access
private boolean backstage;
// Stores the name of the band
private String bandName;
// Constructor with seat information
public Concert(String venue, char row, int seat, String sectionRow, boolean standing, boolean backstage, String bandName) {
super(venue, row, seat, sectionRow);
this.standing = standing;
this.backstage = backstage;
this.bandName = bandName;
}
// Constructor without seat information (for standing tickets)
public Concert(String venue, boolean standing, boolean backstage, String bandName) {
super(venue);
this.standing = standing;
this.backstage = backstage;
this.bandName = bandName;
}
@Override
public void adjustPrice() {
double tempPrice = this.getPrice();
if (standing) {
tempPrice /= 2; // Discount for standing tickets
}
if (backstage) {
tempPrice *= 3; // Increase for backstage access
}
this.setPrice(tempPrice);
}
// Returns if the ticket is for standing
public boolean isStanding() {
return standing;
}
// Returns the band name
public String getBandName() {
return bandName;
}
@Override
public void getTicket() {
System.out.println("Price: " + this.getPrice());
System.out.println("Venue: " + this.getVenue());
if (!standing) {
System.out.println("Seat: " + this.getSectionRow());
} else {
System.out.println("Standing Ticket");
}
if (backstage) {
System.out.println("Backstage Ticket");
}
System.out.println("Band Name: " + bandName);
}
@Override
public String getTicketDetails() {
StringBuilder details = new StringBuilder(super.getTicketDetails());
details.append("Event Type: Concert\n");
if (standing) {
details.append("Standing Ticket\n");
} else {
details.append("Seat: ").append(this.getSectionRow()).append("\n");
}
if (backstage) {
details.append("Backstage Access\n");
}
details.append("Band Name: ").append(bandName).append("\n");
return details.toString();
}
}