catch(SQLiteException e){}
public static interface Action {
void apply(int power);
String getActionName();
}
public static class JumpAction implements Action {
private int gravity;
public JumpAction(int gravity) {
this.gravity = gravity;
}
@Override
public void apply(int power) {
if (power > gravity) {
System.out.println("прыгает на " + (power - gravity) + " метров...");
} else {
System.out.println("немогу подпрыгнуть...");
}
}
@Override
public String getActionName() {
return "прыжок";
}
}
public static interface Human {
void doAction(Action action);
}
public static class Man implements Human {
public String name;
private int power = 10;
public Man(String name) {
this.name = name;
}
@Override
public void doAction(Action action) {
System.out.println(name + " делает " + action.getActionName());
action.apply(power);
}
}
public static class Woman implements Human {
public String name;
private int power = 7;
public Woman(String name) {
this.name = name;
}
@Override
public void doAction(Action action) {
System.out.println(name + " вертя задницей делает " + action.getActionName());
action.apply(power);
}
}
public static void main(String[] args) {
JumpAction jump = new JumpAction(8);
Man man = new Man("Анатолий");
man.doAction(jump);
Woman woman = new Woman("Наталья");
woman.doAction(jump);
}
Анатолий делает прыжок
прыгает на 2 метров...
Наталья вертя задницей делает прыжок
немогу подпрыгнуть...
_, err = stmtIns.Exec(i, (i * i)) // Insert tuples (i, i^2)
if err != nil {
panic(err.Error()) // proper error handling instead of panic in your app
}