Created
June 28, 2017 05:36
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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