package com.bernard.mcqinator.api.fragen;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * @author mysaa
 * @date on 3/13/18.
 */

public class TextFrage extends Frage {
    private final String frage;
    private final String richtigAntwort;

    public TextFrage(String frage, String richtigAntwort) {
        this.frage = frage;
        this.richtigAntwort = richtigAntwort;
    }

    public String getFrage() {
        return frage;
    }

    public String getRichtigAntwort() {
        return richtigAntwort;
    }

    public static Parcelable.Creator<TextFrage> CREATOR =  new Parcelable.Creator<TextFrage>() {
        @Override
        public TextFrage createFromParcel(Parcel source) {
            String frage = source.readString();
            String richtigAntwort = source.readString();
            return new TextFrage(frage,richtigAntwort);
        }

        @Override
        public TextFrage[] newArray(int size) {
            return new TextFrage[size];
        }

    };

    @Override
    public int describeContents() {return 0;}

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(frage);
        dest.writeString(richtigAntwort);
    }

    @Override
    public Class<? extends Frage.Reply> getReplyClass() {
        return TextFrage.Reply.class;
    }

    @Override
    public String toString() {
        return "BlocFrage{" +
                "frage='" + frage + '\'' +
                ", richtigAntwort='" + richtigAntwort + '\'' +
                "} " + super.toString();
    }

    public static class Reply extends Frage.Reply{
        final String answered;

        public Reply(String answered) {
            this.answered = answered;
        }

        public String getAnswered() {
            return answered;
        }

        public static Parcelable.Creator<TextFrage.Reply> CREATOR = new TextFrage.Creator<TextFrage.Reply>() {
            public TextFrage.Reply createFromParcel(Parcel source) {
                return new TextFrage.Reply(source.readString());
            }

            @Override
            public TextFrage.Reply[] newArray(int size) {
                return new TextFrage.Reply[size];
            }
        };


        @Override
        public int describeContents() {return 0;}

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(answered);
        }

    }
}
