-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBattery.java
More file actions
35 lines (33 loc) · 818 Bytes
/
Battery.java
File metadata and controls
35 lines (33 loc) · 818 Bytes
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
public class Battery {
double mAH;
int mMinVoltage;
int mMaxVoltage;
int mTime;
double mElapsedTime;
Battery(int pAH, int pMinVoltage, int pMaxVoltage, int pTime){
mAH = pAH;
mMinVoltage = pMinVoltage;
mMaxVoltage = pMaxVoltage;
mTime = pTime;
mElapsedTime = 0;
}
//mAH = T * ampOutput
double outputAmps(){
if(mElapsedTime < mTime) {
mElapsedTime = mElapsedTime + 1;
return mAH / mTime;
}
else {
System.out.println("Batteries are empty");
return 0;
}
}
void receiveEnergy(double amps){
if(amps <= 25){
mElapsedTime--;
}
else{
mElapsedTime = mElapsedTime - 2;
}
}
}