package QCM;

import java.io.Serializable;
import java.util.*;


public class Reponse implements Comparable<Reponse>,Serializable{
	private String libelle = new String();
	private boolean vrai;
	private int ordre;
	private Scanner sc;

//gettet et setter
public String getLibelle() {
	return libelle;
}
public void setLibelle(String libelle) {
	this.libelle = libelle;
}
public boolean isVrai() {
	return vrai;
}
public void setVrai(boolean vrai) {

	this.vrai = vrai;
}
public int getOrdre() {
	return ordre;
}

//constructeur
public Reponse(String libelle, boolean vrai, int ordre){
	this.libelle=libelle;
	this.vrai=vrai;
	this.ordre=ordre;
}

public Reponse(){
	
}

//fonction creer reponse
public Reponse  creerReponse(int ordre){
	sc = new Scanner(System.in);
	boolean vrai;
	
	System.out.println("Quel est le libellé de la réponse");
	String libelle=sc.nextLine();
	
	System.out.println("La reponse est elle true ou false");
	String v=sc.nextLine();
	if(v.equals("true")){
		vrai=true;
		
	}
	else vrai=false;
	Reponse r=new Reponse(libelle, vrai, ordre);
	return r;
}

//fonction afficher reponse
public void afficherReponse(Reponse r){
		System.out.println("vous avez saissi :" +" "+ r );
}


//fonction modifier reponse
public Reponse modifierReponse(Reponse r){
	sc = new Scanner(System.in);
	
	afficherReponse(r);
	System.out.println("Voulez vous modifier le libelle (taper oui ou non)");
	String lib=sc.nextLine();
	if(lib.equals("oui")) 
	{
		System.out.println("Par quoi voulez vous le remplacer?");
		String newlibelle=sc.nextLine();
		r.setLibelle(newlibelle);
		
		System.out.println("La reponse est elle vrai ou fause?(taper vrai ou faux)");
		String verite=sc.nextLine();
		if(verite.equals("vrai")) r.setVrai(true);
		else r.setVrai(false);
	}
	
	
	return r;
}


//fontion pour comparer deux réponses
public int compareTo(Reponse other) {
	int b;
	b=other.ordre;
	int d;
	d=this.ordre;
	if (d<b) {return -1;}
	else if (d>b) {return 1;}
	else
	return 0;   
}
//affichage
@Override
public String toString() {
        return  this.getLibelle();
}




}
