/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication60;


import eu.epfc.prm2.Array;
import java.util.Scanner;
import seqint.SeqInt;
import seqint.SeqIntIterator;

/**
 *
 * @author joelx
 */
public class JavaApplication60 {

    /**
     * @param bi
     * @param v
     * @param args the command line arguments
     * @return 
     */
//    public static String renverse(String s){
//        if(s.length()==1){
//            return s;
//        }
//        return renverse(s.substring(1)) + s.charAt(0);
//    }
 

    //pre : val >= 0
//    public static void afficheALEnvers(int val){
//        if(val < 10)
//            System.out.println(val);
//        else{
//            System.out.print(val % 10);
//            afficheALEnvers(val / 10);
//        }
//    }
//    
//    public static void main(String[] args) {
//        System.out.print("Entrez un nombre positif : ");
//        Scanner in = new Scanner(System.in);
//        int nb = in.nextInt();
//        System.out.print("Le revoilà dans l'autre sens : ");
//        afficheALEnvers(nb);
        public static int nbApparitions(int val, SeqInt s) {
        SeqIntIterator it = s.iterator();
        int result = 0;                     // Nombre initial d'appartions de val = zéro
        while (it.hasNext()) {
            if (it.next() == val) {         // Si l'élément suivant == val
                ++result;                   // On incrémente result
            }
        }
        return result;
    }

    public static void main(String[] args) {
        SeqInt s1 = new SeqInt(5, 2, 1, 1, 1, 2, 2, 7, 7, 7, 7, 1, 2);
        System.out.println(s1);
        System.out.println("Nombre d'apparition de '1' dans la séquence : " + nbApparitions(1,s1));
        System.out.println("Nombre d'apparition de '9' dans la séquence : " + nbApparitions(9,s1));
        SeqInt s2 = new SeqInt();
        System.out.println(s2);
        System.out.println("Nombre d'apparition de '1' dans la séquence : " + nbApparitions(1,s2));
    }
}

//        System.out.println(" voila le mot renverser " +renverse(s));
//        // TODO code application logic here
    
    

