Skip to content

Instantly share code, notes, and snippets.

@cmaggiulli
Created June 28, 2017 05:36
Show Gist options
  • Save cmaggiulli/89f3633e022ed5cae592fcc14635212a to your computer and use it in GitHub Desktop.
Save cmaggiulli/89f3633e022ed5cae592fcc14635212a to your computer and use it in GitHub Desktop.
AlgebraicNotationPoint2D is an extension of javafx.geometry.Point2D for a chess game. Notably it creates a new constructor with a char, double signature for standard algebraic piece notation in chess. It contains a private static converter method which turns the char into a double value representing it's alphabetical index starting at 1. The cha…
package io.github.cmaggiulli.Game;
import javafx.geometry.Point2D;
public class AlgebraicNotationPoint2D extends Point2D {
public AlgebraicNotationPoint2D(char rank, double file) {
super(alphabeticalIndex(rank), file);
}
private static double alphabeticalIndex(char rank) {
int a = (int) 'a';
int letter = (int) rank;
return letter - a + 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment