DM 1 - Erratum


29/02/04 - 10h30
Il y avait une erreur dans le code de la fonction static int numeroLigne(String ligne) de la question 4.
Voici le code corrigé :

  static int numeroLigne(String ligne) {
    if ( ligne == null || ligne.length() == 0 )
      return 0;
    if ( ligne.charAt(0) == '1' )
      if ( ligne.charAt(1) >= '0' && ligne.charAt(1) <= '3' )
        return 10 + ligne.charAt(1) - '0';
      else
        return 1;
    else if ( ligne.charAt(0) >= '1' && ligne.charAt(0) <= '9' )
      return ligne.charAt(0) - '0';
    else if ( ligne.charAt(0) >= 'A' && ligne.charAt(0) <= 'D' )
      return 14 + ligne.charAt(0) - 'A';
    else if ( ligne.charAt(0) == 'P' ) 
      return 18 + ligne.charAt(1) - '1';
    else
      throw new Error ("désignation de ligne incorrecte : "+ ligne);
  }
L'énoncé est mis à jour.


Dernière mise à jour :