Skip to content

Instantly share code, notes, and snippets.

@Announcement
Created May 29, 2014 19:46
Show Gist options
  • Select an option

  • Save Announcement/851ee154dd33c890a1a4 to your computer and use it in GitHub Desktop.

Select an option

Save Announcement/851ee154dd33c890a1a4 to your computer and use it in GitHub Desktop.
derp
public class Family {
public String Data = "";
public Family Left, Right;
public void Family() {}
public void setData(String a) {
Data = a;
}
public Family getRight() {
if (Right == null || Right.isEmpty()) Right = new Family();
return Right;
}
public Family getLeft() {
if (Left == null || Left.isEmpty()) Left = new Family();
return Left;
}
public Boolean hasLeft() {
return !getLeft().isEmpty();
}
public Boolean hasRight() {
return !getRight().isEmpty();
}
public Family setRight(String a) {
getRight().setData(a);
return Right;
}
public Family setLeft(String a) {
getLeft().setData(a);
return Left;
}
public Boolean isEmpty(){
return Data.isEmpty();
}
public String fix(int a){
String txt = "";
if (!isEmpty() && a == 0)
txt+=Data;
if (hasLeft())
txt+=getLeft().fix(a);
if (!isEmpty() && a == 1)
txt+=Data;
if (hasRight())
txt+=getRight().fix(a);
if (!isEmpty() && a == 2)
txt+=Data;
return txt;
}
public String max(String a, String b){
return (a.compareTo(a)>0)?a:b;
}
public String mins(String a, String b){
return (a.compareTo(a)<0)?a:b;
}
public void flip(String a, String b){
String c = a, d = b;
a = maxs(c,d);
b = mins(c,d);
}
d = Math.max(a,b);
final = Math.min(d,Math.max(d,c));
public String sort(){
String a = (Left == null)? "" : Left.sort();
String b = (isEmpty())? "" : Data;
String c = (Right == null)? "" : Right.sort();
Data = mins(maxs(a,b),c);
return Data;
}
@Override public String toString() {
return Data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment