Skip to content

Instantly share code, notes, and snippets.

@tkfx
Last active July 21, 2016 15:39
Show Gist options
  • Save tkfx/f511ab2715e34947c00e70d1363ccd24 to your computer and use it in GitHub Desktop.
Save tkfx/f511ab2715e34947c00e70d1363ccd24 to your computer and use it in GitHub Desktop.
private static void calcLine(int a, int b, int from, int to) {
Line l = new Line(a, b);
for (int x = from; x <= to; x++) {
int y = l.getY(x);
System.err.println("(" + x + ", " + y + ")");
}
}
static class Line {
public final int a;
public final int b;
public Line(int a, int b) {
this.a = a;
this.b = b;
}
// Inlining
public int getY(int x) {
return (a * x + b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment