Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Below i have two different classes, one that has the symbols (TokenType) and the

ID: 3584976 • Letter: B

Question

Below i have two different classes, one that has the symbols (TokenType) and the other which has the number code for that symbol (Codes). how would i put the code numbers to the TokenType class?

public enum TokenType {

INTEGER(null),

FLOAT(null),

IDENTIFIER(null),

STRING(null),

LEFT_PARENTHESIS("("),

RIGHT_PARENTHESIS(")"),

LEFT_BRACKET("["),

RIGHT_BRACKET("]"),

public class Codes {

public static final int INTEGER_CODE = 1000;

public static final int FLOAT_CODE = 1001;

public static final int IDENTIFIER_CODE = 1002;

public static final int STRING_CODE = 1003;

public static final int LEFT_PARENTHESIS = 1100;

public static final int RIGHT_PARENTHESIS = 1101;

public static final int LEFT_BRACKET = 1102;

Explanation / Answer

Answer:

public enum TokenType {

INTEGER(Codes .INTEGER_CODE ),

FLOAT(Codes.FLOAT_CODE ),

IDENTIFIER(Codes.IDENTIFIER_CODE ),

STRING(Codes.STRING_CODE ),

LEFT_PARENTHESIS(Codes.LEFT_PARENTHESIS ),

RIGHT_PARENTHESIS(Codes.RIGHT_PARENTHESIS ),

LEFT_BRACKET(Codes.LEFT_BRACKET ),

RIGHT_BRACKET(Codes.RIGHT_PARENTHESIS)

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote