-
Notifications
You must be signed in to change notification settings - Fork 1
/
SkipCard.java
84 lines (67 loc) · 2.19 KB
/
SkipCard.java
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* This class represent a skip card in UNO game.
* It extends from {@code Card} class
*
*
* @author Mohammad Mahdi Malmasi
* @version 0.1.3
*
* @see Card
*/
public class SkipCard extends Card
{
/* Constructor */
/**
* Creat a new skip card with given details
*
* @param cardColor : the color of the card
* @param cardCode : the code number of the card. an int in range [1, 108]
*/
public SkipCard(Color cardColor, int cardCode)
{
super(20, cardColor, cardCode);
}
/* Methods */
/**
* This method return the {@code String} of the each line of the visual card for print it
* in terminal. if the given number be less than 0, the super class toSetirng will be called.
*
*
* @param lineNumber : the number of the card line
* @return a {@code String} of the given card line
*
* @see cardsOutput.txt, (in project repository)
*/
@Override
public String toString(int lineNumber)
{
if (lineNumber < 0)
return super.toString((-1)*lineNumber);
String cardColorCode = Color.getColorCodeString(super.getCardColor());
switch (lineNumber)
{
// the top and bottom of the card
case 1:
case 7:
return cardColorCode + "•~~~~~~~•" +
Color.getColorCodeString(Color.RESET);
case 2:
return cardColorCode + "|⍉ |" +
Color.getColorCodeString(Color.RESET);
case 3:
case 5:
return cardColorCode + "| |" +
Color.getColorCodeString(Color.RESET);
case 4:
return cardColorCode + "|S k i p|" +
Color.getColorCodeString(Color.RESET);
case 6:
return cardColorCode + "| ⍉|" +
Color.getColorCodeString(Color.RESET);
case 8:
return Color.getColorCodeString(Color.WHITE) + "code: " + super.getCardCode() +
Color.getColorCodeString(Color.RESET);
}
return null;
}
}