Skip to content

Instantly share code, notes, and snippets.

@mattcunningham
Last active January 18, 2017 18:48
Show Gist options
  • Save mattcunningham/6752e1bb7d64bc8145993011adbedded to your computer and use it in GitHub Desktop.
Save mattcunningham/6752e1bb7d64bc8145993011adbedded to your computer and use it in GitHub Desktop.
public class Tabby extends Cat {
public String meow() {
return "meow meow";
}
}
public class Siamese extends Cat {
public String meow() {
return "if you please";
}
}
public class Siamese extends Cat {
public String meow() {
return "if you please";
}
}
public class Square extends Shape {
public Square(int squareSize) {
super(squareSize, squareSize);
}
public int getArea() {
return width * height;
}
}
public class Secret implements Encrypt {
private String[][] secretMessage = new String[4][3];
private int originalLength;
public Secret(String code) {
char[] chars = code.toCharArray();
String[] letters = new String[12];
originalLength = chars.length;
for (int i = 0; i < chars.length; i++) {
letters[i] = Character.toString(chars[i]);
}
for (int filler = chars.length; filler < 12; filler++) {
letters[filler] = ".";
}
for (int row = 0; row < 4; row++) {
for (int column = 0; column < 3; column++) {
secretMessage[row][column] = letters[(row*3)+column];
}
}
}
public String encode() {
String ret = "";
for (int column = 0; column < 3; column++) {
for (int row = 0; row < 4; row++) {
ret += secretMessage[row][column];
}
}
return ret;
}
public String decode() {
String ret = "";
int length = 0;
for (int row = 0; row < 4; row++) {
for (int column = 0; column < 3; column++) {
ret += secretMessage[row][column];
length++;
if (length >= originalLength) break;
}
}
return ret;
}
public String[][] getSecretMessage() {
return secretMessage;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment