Bonjour à tous,
J'ai écrit une énumération en Java que j'aimerais traduire en C++ dans le cadre d'un projet mais je n'arrive pas à trouver de solution pour "traduire" du Java au C++. Des conseils ? Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
public enum Move {
 
	UP(0, -1), DOWN(0, 1), RIGHT(1, 0), LEFT(-1, 0);
 
	private int horizontalMove;
	private int verticalMove;
 
	private Move(int horizontal, int vertical) {
		this.horizontalMove = horizontal;
		this.verticalMove = vertical;
	}
 
	public int getHorizontalMove() {
		return horizontalMove;
	}
 
	public int getVerticalMove() {
		return verticalMove;
	}
 
	public CellLocation getNextCellLocation(CellLocation currentLocation) {
		return new CellLocation(getNextRow(currentLocation.getRowIndex()),
				getNextColumn(currentLocation.getColumnIndex()));
	}
 
	private int getNextRow(int currentRow) {
		return currentRow + verticalMove;
	}
 
	private int getNextColumn(int currentColumn) {
		return currentColumn + horizontalMove;
	}
 
	public Move getInverse() {
		switch (this) {
		case UP:
			return DOWN;
		case DOWN:
			return UP;
		case LEFT:
			return RIGHT;
		case RIGHT:
			return LEFT;
 
		}
		return null;
	}
}
Comme vous pouvez le voir, il s'agit d'une énumération qui me permet de me déplacer dans un tableau 2D.
Merci d'avance à tous et à toutes.