This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog | |
def get_name(name) | |
@name = name | |
end | |
def bark | |
puts "My name is #{@name}!" | |
end | |
end | |
bingo = Dog.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Game | |
attr_accessor :state ,:player | |
# attr_accessor 會自動設定getter和setter | |
def initialize(k=[' ']*9 ,p='X') | |
@state = k | |
@player = p | |
end | |
def opponent | |
if @player == 'X' |