0
Good afternoon my dear I’m having a problem with the logic of this program which is a clock:
private void updateDisplay() {
if(hours.getValue()==0 && (periodo=="am" || periodo =="AM")){
hours.setValue(hours.getValue()+1);
periodo = "am";
}
else{
if(hours.getValue()==12 && (periodo=="am" || periodo =="AM")){
periodo="pm";
}
else{
}
}
if(hours.getValue()==0 && (periodo=="pm" || periodo =="PM")){
hours.setValue(hours.getValue()+1);
periodo="pm";
}
else{
}
displayString = hours.getDisplayValue() + ":" +
minutes.getDisplayValue() + " " + periodo;
}
}
All functions are perfect really is just the part of logic that’s complicated. And I want to limit between 1-12 so when it reaches the limit that is 11:59 pm it turns 12:00 am and when it arrives 11:59 am it turns 12:00 pm.
example when it comes to 11:58 am and I call the minute jump method goes to 11:59 am and repeating again goes to 12:00 am being q should be pm because these two iff so conflicting I guess there prevails the am q is the last qnd is in the 12 hour period.
– Renan Avila