Séparé les classes dans des fichiers
This commit is contained in:
1 parent
bd860b48ff
commit
657eadadde
2 files changed
+12
-12
No files matched your search
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
class Player
|
class Player
|
||||||
attr_reader :player_name, :hand, :score
|
attr_reader :name, :hand, :score
|
||||||
|
|
||||||
def initialize(player_name)
|
def initialize(name)
|
||||||
@hand = []
|
@hand = []
|
||||||
@player_name = player_name
|
@player_name = name
|
||||||
@score = 0
|
@score = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require_relative "lib/game"
|
require_relative "lib/game"
|
||||||
|
|
||||||
@@ -6,23 +6,23 @@ require_relative "lib/game"
|
|||||||
game = Game.new("Alice", "Bob")
|
game = Game.new("Alice", "Bob")
|
||||||
|
|
||||||
game.determine_dealer
|
game.determine_dealer
|
||||||
puts "The dealer is #{game.dealer.player_name}."
|
puts "The dealer is #{game.dealer.name}."
|
||||||
game.deal
|
game.deal
|
||||||
puts "#{game.player1.player_name} has #{game.player1.hand.count} cards."
|
puts "#{game.player1.name} has #{game.player1.hand.count} cards."
|
||||||
puts "#{game.player2.player_name} has #{game.player2.hand.count} cards."
|
puts "#{game.player2.name} has #{game.player2.hand.count} cards."
|
||||||
puts "The stock has #{game.stock.length} cards."
|
puts "The stock has #{game.stock.length} cards."
|
||||||
puts
|
puts
|
||||||
game.change_dealer
|
game.change_dealer
|
||||||
puts "The dealer is #{game.dealer.player_name}."
|
puts "The dealer is #{game.dealer.name}."
|
||||||
game.deal
|
game.deal
|
||||||
puts "#{game.player1.player_name} has #{game.player1.hand.count} cards."
|
puts "#{game.player1.name} has #{game.player1.hand.count} cards."
|
||||||
puts "#{game.player2.player_name} has #{game.player2.hand.count} cards."
|
puts "#{game.player2.name} has #{game.player2.hand.count} cards."
|
||||||
puts "The stock has #{game.stock.length} cards."
|
puts "The stock has #{game.stock.length} cards."
|
||||||
|
|
||||||
# Mise en place du jeu
|
# Mise en place du jeu
|
||||||
# puts "#{game.player1.player_name} has :"
|
# puts "#{game.player1.name} has :"
|
||||||
# puts
|
# puts
|
||||||
# puts "#{game.player2.player_name} has :"
|
# puts "#{game.player2.name} has :"
|
||||||
# puts game.player2.hand
|
# puts game.player2.hand
|
||||||
# puts
|
# puts
|
||||||
# puts "Upcard is #{game.upcard} so the trump suit is #{game.trump_suit}."
|
# puts "Upcard is #{game.upcard} so the trump suit is #{game.trump_suit}."
|
||||||
|
|||||||
Reference in new issue
Block a user