-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicketLab.java
More file actions
101 lines (99 loc) · 2.69 KB
/
Copy pathTicketLab.java
File metadata and controls
101 lines (99 loc) · 2.69 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
//Nancy
public class TicketLab
{
private static int totalTickets = 0;
private static int serialNumber = 10000;
private static int totalDollars = 0;
private static int numWalkUps = 0;
private static int numStudentAdvances = 0;
private static int numAdvances = 0;
private int daysAhead;
private String ticketType;
private int ticketCost;
private boolean isStudent;
public TicketLab (){
daysAhead = 0;
ticketType = "Walk Up";
numWalkUps ++;
totalTickets ++;
serialNumber ++;
ticketCost = findPrice();
totalDollars += ticketCost;
}
public TicketLab (String ticketType){
this.ticketType = ticketType;
if (ticketType.equals("WalkUp")){
daysAhead = 0;
numWalkUps ++;
isStudent = false; //here I just picked an automatic one
}
else { daysAhead = 10;//here I just picked an automatic one
if (ticketType.equals("StudentAdvance")){
isStudent = true;
numStudentAdvances ++;
}
else{
isStudent = false;
numAdvances ++;
}
}
totalTickets ++;
serialNumber ++;
ticketCost = findPrice();
totalDollars += ticketCost;
}
private int findPrice (){
if (daysAhead == 0)
ticketCost = 50;
else{
if (daysAhead < 10)
ticketCost = 40;
else
ticketCost = 30;
if (isStudent)
ticketCost /= 2;
}
return ticketCost;
}
/* unnecessary mutator methods
public void pickSerialNum (int serialNumber){
this.serialNumber = serialNumber;
}
public void changeDaysAhead (int daysAhead){
daysAhead = this.daysAhead;
}
public void changeStudent (boolean isStudent){
isStudent = this.isStudent;
}
*/
public static int getTotalTickets(){
return totalTickets;
}
public static int getNumWalkUps(){
return numWalkUps;
}
public static int getNumStudentAdvances(){
return numStudentAdvances;
}
public static int getNumAdvances(){
return numAdvances;
}
public static int getTotalDollars(){
return totalDollars;
}
public static int getSerialNum(){
return serialNumber;
}
public int getDaysAhead(){
return daysAhead;
}
public int getTicketCost(){
return ticketCost;
}
public boolean getStudent(){
return isStudent;
}
public String toString (){
return serialNumber + " " + daysAhead + " " + ticketCost + " " + isStudent;
}
}