-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.rb
65 lines (48 loc) · 851 Bytes
/
player.rb
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
# @lands
# @balance
# @name
# #buy_land
# #pay_rent
# #receive_rent
# #check_balance
require './land'
class Player
def initialize (balance, name)
@land = []
@balance = balance
@name = name
# => @value = Land.new
end
def buy_land(land)
# NO check if it exists
# check availablity
# if yes check value and compare with balance
# if balance => value then buy it
# add to land list = update ownership
# update balance
if land.available? && @value <= @balance
@land << land
@balance = @balance - @value
end
end
def value
Land.value
end
def pay_rent
#check ownership
# if yes pay rent to owner
# update balance
@balance - @rent unless @owner.nil?
end
def receive_rent
@balance = @balance + @rent
end
def check_balance
@balance
end
def
def to_s
@name
end
end
print Land.value