-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.rb
More file actions
51 lines (47 loc) · 1.11 KB
/
Card.rb
File metadata and controls
51 lines (47 loc) · 1.11 KB
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
require 'colorize'
# This class requires the gem 'colorize'
# This class makes an individual card with properties:
# shape, number of shapes, color and shading
#
# The characteristics are defined as follows:
#
# First Element = Shape
# 1->Diamond
# 2->Oval
# 3->Square
# Second Element = Number
# 1->1
# 2->2
# 3->3
# Third Element = Color
# 1->Red
# 2->Blue
# 3->Green
# Fourth Element = Shading
# 1->Shaded
# 2->Empty
# 3->Striped
class Card
# get_code: Creates a shallow copy of @card instance
# but does not copy the reference
#
# Returns a copy of the card
def get_code
@card.clone
end
# initialize: Creates a new instance of Card that
# that sets the Card properties based
# on the array of properties input
#
# properties - The desired properties for the card
#
# Example:
#
# card1 = Card.new [1,2,2,3]
# # => A card with 2 striped red diamonds
#
# Returns a card with the desired properties
def initialize(properties)
@card = properties
end
end