Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Caesar-cipher/Objeck/caesar-cipher.objeck
Normal file
29
Task/Caesar-cipher/Objeck/caesar-cipher.objeck
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
class Caesar {
|
||||
function : native : Encode(enc : String, offset : Int) ~ String {
|
||||
offset := offset % 26 + 26;
|
||||
encoded := "";
|
||||
enc := enc->ToLower();
|
||||
each(i : enc) {
|
||||
c := enc->Get(i);
|
||||
if(c->IsChar()) {
|
||||
j := (c - 'a' + offset) % 26;
|
||||
encoded->Append(j + 'a');
|
||||
}
|
||||
else {
|
||||
encoded->Append(c);
|
||||
};
|
||||
};
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
function : Decode(enc : String, offset : Int) ~ String {
|
||||
return Encode(enc, offset * -1);
|
||||
}
|
||||
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
enc := Encode("The quick brown fox Jumped over the lazy Dog", 12);
|
||||
enc->PrintLine();
|
||||
Decode(enc, 12)->PrintLine();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue