Add method which calculates the amount of seconds that were needed to solve a DailySudoku object based on its "timeNeeded" attribute
This commit is contained in:
parent
a015bd5597
commit
91f7cc6d2b
1 changed files with 14 additions and 0 deletions
|
@ -25,6 +25,20 @@ public class DailySudoku extends Level {
|
||||||
return timeNeeded;
|
return timeNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTimeNeededInSeconds() {
|
||||||
|
if (timeNeeded.matches("/d/d:/d/d:/d/d")) {
|
||||||
|
String[] timeInstances = timeNeeded.split(":");
|
||||||
|
int hourIndex = 0;
|
||||||
|
int minuteIndex = 1;
|
||||||
|
int secondIndex = 2;
|
||||||
|
|
||||||
|
int minutes = Integer.parseInt(timeInstances[hourIndex]) * 60 + Integer.parseInt(timeInstances[minuteIndex]);
|
||||||
|
return minutes * 60 + Integer.parseInt(timeInstances[secondIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTimeNeeded(String timeNeeded) {
|
public void setTimeNeeded(String timeNeeded) {
|
||||||
this.timeNeeded = timeNeeded;
|
this.timeNeeded = timeNeeded;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue