-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColoredToken.java
More file actions
41 lines (36 loc) · 1011 Bytes
/
Copy pathColoredToken.java
File metadata and controls
41 lines (36 loc) · 1011 Bytes
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
/**
* ColoredToken is a concrete class which hold the Token in colored form.
*/
public class ColoredToken extends Token {
String color;
/**
* ColoredToken is default constructor with pre-initialized token value.
*/
public ColoredToken() {
super(' ');
this.color = Colors.BACKGROUND_BRIGHT_WHITE;
}
/**
* Constructor which accepts token character as input
*
* @param token is a token character.
*/
public ColoredToken(char token) {
super(token);
this.color = Colors.BACKGROUND_BRIGHT_WHITE + Colors.BRIGHT_GREEN;
}
/**
* Constructor which accepts both token character and color.
*
* @param token is a token character
* @param color is a color to be applied during rendering.
*/
public ColoredToken(char token, String color) {
super(token);
this.color = color;
}
@Override
public String toString() {
return color + token + Colors.RESET;
}
}