31 lines
603 B
Java
31 lines
603 B
Java
|
package question2;
|
||
|
|
||
|
public class Cesar extends AlgoCodage{
|
||
|
|
||
|
private int decalage;
|
||
|
private String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||
|
|
||
|
public Cesar(int decalage){
|
||
|
this.nom = "César";
|
||
|
this.decalage = decalage;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String encode(String s) {
|
||
|
String encode = "";
|
||
|
for(int i=0;i<s.length();i++){
|
||
|
encode += alphabet.charAt((decalage +
|
||
|
alphabet.indexOf(s.charAt(i)))%alphabet.length());
|
||
|
}
|
||
|
return encode;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String decode(String s) {
|
||
|
return "Fonctionnalité décodage de César pas encore implémenté";
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|