-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard.js
55 lines (46 loc) · 941 Bytes
/
card.js
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
(function () {
this.Card = function(rank, suit) {
var rank = rank;
var suit = suit;
var rankLiteral;
switch (rank) {
case 1:
rankLiteral = "Ace";
break;
case 2:
rankLiteral = "Deuce";
break;
case 11:
rankLiteral = "Jack";
break;
case 12:
rankLiteral = "Queen";
break;
case 13:
rankLiteral = "King";
break;
default:
rankLiteral = rank;
}
function literal() {
var res = "";
if (suit === "Joker") {
res = "Joker";
} else {
res = rankLiteral + " of " + suit;
}
return res;
}
function code() {
var r = rankLiteral.toString().charAt(0).toUpperCase();
var s = suit.charAt(0).toLowerCase();
return r + s;
}
return {
rank: rank,
suit: suit,
literal: literal,
code: code
}
}
})();