glog_td4/td4/question2/Cesar.java

31 lines
603 B
Java
Raw Permalink Normal View History

2018-04-01 12:34:28 +00:00
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é";
}
}