Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Rifqi Mukti W
- * @version 2017.10.12
- */
- public class NumberDisplay
- {
- private int limit;
- private int value;
- /**
- * Constructor untuk NumberDisplay
- * Set limit dimana display akan berganti dari batas maks ke 08.
- */
- public NumberDisplay(int rollOverLimit)
- {
- limit = rollOverLimit;
- value = 0;
- }
- /**
- * Return value sekarang.
- */
- public int getValue()
- {
- return value;
- }
- /**
- * Return value display (jika di string kurang dari 10, seperti misal
- * 3.5, maka ditambah 0 didepannya menjadi 03.05)
- */
- public String getDisplayValue()
- {
- if(value < 10) {
- return "0" + value;
- }
- else {
- return "" + value;
- }
- }
- /**
- * Ubah value di display. Jika value kurang dari 0 atau lebih dari limit,
- * tidak dilakukan apa-apa.
- */
- public void setValue(int replacementValue)
- {
- if((replacementValue >= 0) && (replacementValue < limit)) {
- value = replacementValue;
- }
- }
- /**
- * Increment satu display value, jika mencapai limit maka menjadi 0
- */
- public void increment()
- {
- value = (value + 1) % limit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement