-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMember.java
179 lines (144 loc) · 5.14 KB
/
Member.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import java.time.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Member extends Person {
private int type;
private double fee;
public static double oneMonthRate = 100;
public static double threeMonthRate = 95;
public static double sixMonthRate = 90;
public static double yearlyRate = 80;
public static double studentDiscount = 0.9;// for now.(10%)
public double discount;
//public WorkoutClass[] registeredClasses = new ;
public int months;
//public WeeklyCalender memberSchedule;
//public List<int[]> filledSlotsIndex = new ArrayList<int[]>(); // {[1,0], [1,1], ...} has the addresses that contain
// true
public Member(String fn, String ln, LocalDate dob, String email, LocalDate startDate, LocalDate endDate, int type, int months) throws NegativeNumberException {
// this constructor is if the user inputs months start date and end date
super(fn, ln, dob, email, startDate, endDate);
this.type = type;
this.months = months;
this.fee = calculateFees(type, this.months);
//this.memberSchedule = memberSchedule;
// this.memberSchedule.resetCalender();//set all slots to false
}
public Member(String fn, String ln, LocalDate dob, String email, LocalDate startDate, int type, int months) throws NegativeNumberException {
// this constructor is if the user only inputs months and start date
super(fn, ln, dob, email);
super.setStartDate(startDate);
LocalDate endDate = startDate.plusMonths(Integer.toUnsignedLong(months));// can throw InputMismatchException and
// if a negative is given it is
// converted to a large number
// making it apparent but not
// throwing an error
super.setEndDate(endDate);
this.type = type;
this.months = months;
this.fee = calculateFees(type, this.months);
//this.memberSchedule = memberSchedule;
//this.memberSchedule.resetCalender();
// set all slots to false
}
public Member(String fn, String ln, LocalDate dob, String email, int type, int months) throws NegativeNumberException {
// this constructor is if the user only inputs months
super(fn, ln, dob, email);
LocalDate startDate = LocalDate.now();
super.setStartDate(startDate);
LocalDate endDate = startDate.plusMonths(Integer.toUnsignedLong(months));
super.setEndDate(endDate);
this.type = type;
this.months = months;
this.fee = calculateFees(type, this.months);
//this.memberSchedule = memberSchedule;
//this.memberSchedule.resetCalender();
// set all slots to false
}
public double calculateFees(int Type, int Months) throws NegativeNumberException {
if(Months < 0)
{
throw new NegativeNumberException("Error, Months can't be negative");
}
if (type == 1) {
if (months == 3) {
return months * threeMonthRate * studentDiscount;
}
else if (months == 6) {
return months * sixMonthRate * studentDiscount;
}
else if (months == 12) {
return months * yearlyRate * studentDiscount;
}
else {
return months * oneMonthRate * studentDiscount;
}
}
else {
if (months == 3) {
return months * threeMonthRate;
}
else if (months == 6) {
return months * sixMonthRate;
}
else if (months == 12) {
return months * yearlyRate;
}
else {
return months * oneMonthRate;
}
}
}
public double getFee() {
return this.fee;
}
public String getType() {
if (type == 1) {
return "Student member";
} else {
return "Regular member";
}
}
public void setType(int Type) throws NegativeNumberException {
this.type = Type;
setFees(calculateFees(Type, months));
}
public void setFees(double fees) {
this.fee = fees;
}
/*
public void addCLassesToSchedule() throws SlotFilledException {
// add exception if schedule is already filled
for (WorkoutClass workoutClass : this.registeredClasses) { // loop through classes in resgisteredClasses[]
// array; each class is stored in workoutClass
for (int columns = 0; columns < 7; columns++) { // loop through columns for each
// WorkoutCourse.weeklySchedule in the ^ array
for (int rows = 0; rows < 72; rows++) { // loop through the rows (times)
if (workoutClass.workoutSchedule.WeeklySchedule[columns][rows]
&& !this.memberSchedule.WeeklySchedule[columns][rows]) {
throw new SlotFilledException("this slot is already filled");
}
if (workoutClass.workoutSchedule.WeeklySchedule[columns][rows]) { // checks if this
// WorkoutCourse.workoutSchedule
// slot has a true in it and if
// so,
this.memberSchedule.WeeklySchedule[columns][rows] = true; // adds true to the corresponding
// Member.memberSchedule.WeeklySchedule
// cell
int[] address = { columns, rows }; // update the filled slots index
this.filledSlotsIndex.add(address);
}
}
}
}
}
*/
/*
* // to do
* add a method to remove classes from schedule add method that updates
* the registered classes and calls the addClassToSchedule() or the remove class
* method. or should this be in the main?
*
*/
}