package ui.controller; import ui.model.Model; public class AutoSaveController { private Model MODEL; private int max = Integer.MAX_VALUE; private int numberOfSaves = 20; private int currentSave; private int count = 0; private boolean isAllowed = false; public AutoSaveController(Model model) { this.MODEL = model; } public void increaseAutoSaveNr() { currentSave = MODEL.getAutoSaveNr() + 1; if (count < currentSave) { count = currentSave; } if (numberOfSaves == count) { isAllowed = true; } if (currentSave > max) { currentSave = 0; } MODEL.setAutoSaveNr(currentSave); } public void decreaseAutoSaveNr() { currentSave = MODEL.getAutoSaveNr() - 1; // if (currentSave < 0) { // currentSave = max; // } MODEL.setAutoSaveNr(currentSave); } public int getAutoSaveNr() { return MODEL.getAutoSaveNr(); } public boolean allowed() { return isAllowed; } }