Skip to content

Instantly share code, notes, and snippets.

@sakamotodesu
Created May 22, 2013 10:24
Show Gist options
  • Save sakamotodesu/5626614 to your computer and use it in GitHub Desktop.
Save sakamotodesu/5626614 to your computer and use it in GitHub Desktop.
酒と泪と男と女をオブジェクト指向で表現してみた
public class Man extends Human {
@Override
void ProtectMyself() {
drink(new Happoushu());
}
private void drink(Alcohol alcohol) {
if (alcohol != null) {
memory = null;
sleep = true;
}
}
}
public class Woman extends Human {
@Override
void ProtectMyself() {
cry();
}
private Tears cry() {
new Tears();
new Tears();
new Tears();
memory = null;
return new Tears();
}
}
public abstract class Human {
protected Object memory;
protected boolean sleep;
public void sadEvent() {
ProtectMyself();
}
abstract void ProtectMyself();
}
public class Happoushu implements Alcohol {
}
interface Alcohol extends Water {
}
public class Tears implements Water {
}
public interface Water {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment