-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcandy.js
41 lines (35 loc) · 845 Bytes
/
candy.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
/* Copyright (c) 2017 MIT 6.813/6.831 course staff, all rights reserved.
* Redistribution of original or derived work requires permission of course staff.
*/
/**
* This object represents a candy on the board. Candies have a row
* and a column, and a color
*/
var Candy = function(color, id)
{
////////////////////////////////////////////////
// Representation
//
// Two immutable properties
Object.defineProperty(this, 'color', {value: color, writable: false});
Object.defineProperty(this, 'id', {value: id, writable: false});
// Two mutable properties
this.row = null;
this.col = null;
////////////////////////////////////////////////
// Public methods
//
this.toString = function()
{
var name = this.color;
return name;
}
};
Candy.colors = [
'red',
'yellow',
'green',
'orange',
'blue',
'purple'
];