// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/DataEvent.java
// public class DataEvent<T> {
//     private List<DataEventListener<T>> listeners = new ArrayList<>();
// 
//     public void addListener(DataEventListener<T> listener) {
//         listeners.add(listener);
//     }
// 
//     public void dispatch(T data) {
//         for (DataEventListener<T> listener : listeners) {
//             listener.onDispatch(data);
//         }
//     }
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/DataEventListener.java
// public interface DataEventListener<T> {
//     void onDispatch(T data);
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/Event.java
// public class Event {
//     private List<EventListener> listeners = new ArrayList<>();
// 
//     public void addListener(EventListener listener) {
//         listeners.add(listener);
//     }
// 
//     public void dispatch() {
//         for (EventListener listener : listeners) {
//             listener.onDispatch();
//         }
//     }
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/EventListener.java
// public interface EventListener {
//     void onDispatch();
// }
// 
// Path: chapter5-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/state/StateLoader.java
// public interface StateLoader {
//     int loadInt(String key, int defaultIfNotFound);
//     boolean loadBool(String key, boolean defaultIfNotFound);
// }
// 
// Path: chapter5-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/state/StateSaver.java
// public interface StateSaver {
//     void saveInt(String key, int value);
//     void saveBool(String key, boolean value);
// }


import com.olerass.pfexample.android.geoquiz.domain.event.DataEvent;
import com.olerass.pfexample.android.geoquiz.domain.event.DataEventListener;
import com.olerass.pfexample.android.geoquiz.domain.event.Event;
import com.olerass.pfexample.android.geoquiz.domain.event.EventListener;
import com.olerass.pfexample.android.geoquiz.domain.state.StateLoader;
import com.olerass.pfexample.android.geoquiz.domain.state.StateSaver;
import java.util.HashMap;
import java.util.Map;
    public boolean isCorrectAnswer(boolean answer) {
        return answer == currentQuestionAnswer();
    }

    @Override
    public void gotoNextQuestion() {
        currentIndex = (currentIndex + 1) % questions.length;
        questionTextChangedEvent.dispatch();
    }

    @Override
    public void cheatRequested() {
        cheatRequestedEvent.dispatch(currentQuestionAnswer());
    }

    @Override
    public void whenQuestionTextChanged(EventListener listener) {
        questionTextChangedEvent.addListener(listener);
    }

    public void whenCheatRequested(DataEventListener<Boolean> listener) {
        cheatRequestedEvent.addListener(listener);
    }

    public void setCheatedOnCurrentQuestion(boolean cheated) {
        cheatMap.put("CHEAT_" + currentIndex, cheated);
    }

    public void saveState(StateSaver stateSaver) {
        stateSaver.saveInt(KEY_INDEX, currentIndex);
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/DataEvent.java
// public class DataEvent<T> {
//     private List<DataEventListener<T>> listeners = new ArrayList<>();
// 
//     public void addListener(DataEventListener<T> listener) {
//         listeners.add(listener);
//     }
// 
//     public void dispatch(T data) {
//         for (DataEventListener<T> listener : listeners) {
//             listener.onDispatch(data);
//         }
//     }
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/DataEventListener.java
// public interface DataEventListener<T> {
//     void onDispatch(T data);
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/Event.java
// public class Event {
//     private List<EventListener> listeners = new ArrayList<>();
// 
//     public void addListener(EventListener listener) {
//         listeners.add(listener);
//     }
// 
//     public void dispatch() {
//         for (EventListener listener : listeners) {
//             listener.onDispatch();
//         }
//     }
// }
// 
// Path: chapter6-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/event/EventListener.java
// public interface EventListener {
//     void onDispatch();
// }
// 
// Path: chapter5-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/state/StateLoader.java
// public interface StateLoader {
//     int loadInt(String key, int defaultIfNotFound);
//     boolean loadBool(String key, boolean defaultIfNotFound);
// }
// 
// Path: chapter5-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/state/StateSaver.java
// public interface StateSaver {
//     void saveInt(String key, int value);
//     void saveBool(String key, boolean value);
// }


// Path: chapter5-geoquiz-challenges/app/src/main/java/com/olerass/pfexample/android/geoquiz/domain/question/StandardQuestionModel.java
import com.olerass.pfexample.android.geoquiz.domain.event.DataEvent;
import com.olerass.pfexample.android.geoquiz.domain.event.DataEventListener;
import com.olerass.pfexample.android.geoquiz.domain.event.Event;
import com.olerass.pfexample.android.geoquiz.domain.event.EventListener;
import com.olerass.pfexample.android.geoquiz.domain.state.StateLoader;
import com.olerass.pfexample.android.geoquiz.domain.state.StateSaver;
import java.util.HashMap;
import java.util.Map;

    public boolean isCorrectAnswer(boolean answer) {
        return answer == currentQuestionAnswer();
    }

    @Override
    public void gotoNextQuestion() {
        currentIndex = (currentIndex + 1) % questions.length;
        questionTextChangedEvent.dispatch();
    }

    @Override
    public void cheatRequested() {
        cheatRequestedEvent.dispatch(currentQuestionAnswer());
    }

    @Override
    public void whenQuestionTextChanged(EventListener listener) {
        questionTextChangedEvent.addListener(listener);
    }

    public void whenCheatRequested(DataEventListener<Boolean> listener) {
        cheatRequestedEvent.addListener(listener);
    }

    public void setCheatedOnCurrentQuestion(boolean cheated) {
        cheatMap.put("CHEAT_" + currentIndex, cheated);
    }

    public void saveState(StateSaver stateSaver) {
        stateSaver.saveInt(KEY_INDEX, currentIndex);
        for (Map.Entry<String, Boolean> entry : cheatMap.entrySet()) {