package Java15; import java.io.*; import iao.MesEntreesSorties.ConsoleStandard; class Paire { private A fst; private B snd; public Paire(){} public Paire(A f, B s){fst=f; snd=s;} public A getfst(){return fst;} public B getsnd(){return snd;} public String toString(){return getfst()+"-"+getsnd();} public static void copieFstTab(Paire p, A[] tableau, int i) {tableau[i]=p.getfst();} } interface Saisissable { void saisie(ConsoleStandard c) throws IOException; } class StringSaisissable implements Saisissable { private String s; public StringSaisissable(String s){this.s=s;} public void saisie(ConsoleStandard c) throws IOException {s=c.lireChaine();} public String toString(){return s;} } public class PaireSaisissable implements Saisissable { private A fst; private B snd; public PaireSaisissable(){} public PaireSaisissable(A f, B s){fst=f; snd=s;} public A getfst(){return fst;} public B getsnd(){return snd;} public String toString(){return getfst()+"-"+getsnd();} public void saisie(ConsoleStandard c)throws IOException { System.out.print("Entrer la valeur de first : "); fst.saisie(c); System.out.print("Entrer la valeur de snd : "); snd.saisie(c); } public static void main(String[] a)throws IOException { System.out.println("Test de Paire"); //Paire p= new Paire(9,"plus grand chiffre"); Paire p= new Paire(9,"plus grand chiffre"); int pfst=p.getfst(); String psnd=p.getsnd(); System.out.println("La paire est : ("+pfst+","+psnd+")"); Integer[] tableau = new Integer[2]; Paire.copieFstTab(p,tableau,0); System.out.println("Le tableau contient : "+tableau[0]+" "+tableau[1]); System.out.println("Test de PaireSaisissable"); ConsoleStandard c = new ConsoleStandard(); StringSaisissable s1 = new StringSaisissable(""); StringSaisissable s2 = new StringSaisissable(""); PaireSaisissable mp = new PaireSaisissable(s1,s2); mp.saisie(c); System.out.println("Paire mp = "+mp); } }