forked from jomokojomoko/ICS-PROJECT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Study.java
44 lines (40 loc) · 1.44 KB
/
Study.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
public class Study{
private double hourStudy;
private double effectiveHours;
private final static double MAXHOURS=2;
//Constructor
public Study(double hourStudied ){
hourStudy=hourStudied;
effectiveHours=0;
}
public double getHoursStudy(){
return hourStudy;
}
public void setHoursStudy(double hourStudied){
hourStudy=hourStudied;
}
public double getEffectiveHours(){
return effectiveHours;
}
public void setEffectiveHours(double effective){
effectiveHours=effective;
}
//recursive method to calculate effective hours
public void effectiveCalculator(double hour,double effectiveness,boolean firstTime,double hourDecrease){
//Adds in the max hours at 100% efficiency
if(firstTime==true){
if (hourStudy<=MAXHOURS){
effectiveHours+=hour;
}
else{
effectiveHours+=MAXHOURS;
effectiveCalculator(hour-MAXHOURS,effectiveness*0.9,false,hourDecrease);
}
}
//Recursion part of code that decreases effectiveness and adds effective hours
else if(hour>0){
effectiveHours+=hourDecrease*effectiveness;
effectiveCalculator(hour-hourDecrease,effectiveness*0.9,false,hourDecrease+2);
}
}
}