1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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;
- }
- }
|