-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcard.js
More file actions
30 lines (24 loc) · 724 Bytes
/
card.js
File metadata and controls
30 lines (24 loc) · 724 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
var Card = function(number,suit){
this.number=number;
this.suit=suit;
};
Card.prototype.isHigher = function(otherCard)
{
if(otherCard.suit!=this.suit)
return;
var value = this.number;
var otherValue = otherCard.number;
//1 and 9 ar higher than the other numbers, so make its
if(this.number === 1 || this.number === 9)
value = value*100;
if(otherCard.number === 1 || otherCard.number === 9)
otherValue = otherValue*100;
return value > otherValue;
}
Card.prototype.toString = function()
{
return "[object Card <" + this.number + "-"+this.suit+">]";
}
module.exports.create = function(number,suit) {
return new Card(number,suit);
};