Skip to content

Instantly share code, notes, and snippets.

View pumpkincouture's full-sized avatar

Sylwia Bridges pumpkincouture

View GitHub Profile
class Game
attr_reader :board, :computer_player, :human_player, :ui
def initialize
@board = Board.new
@computer_player = ComputerPlayer.new
@human_player = HumanPlayer.new
@ui = UserInterface.new(human_player)
end
class FizzBuzzGame
def run(x,y)
for i in x..y
if i%5==0 && i%3==0
puts "FizzBuzz"
elsif i%3==0
puts "Fizz"
elsif i%5==0
puts "Buzz"
require './FizzBuzzGame'
describe FizzBuzzGame do
before :each do
@FBGame=FizzBuzzGame.new
end
describe "#new" do
require_relative 'spec_helper.rb'
describe Game do
before :each do
@new_game=Game.new
end
describe "#new" do
it "creates a new instance of Game" do
require_relative 'spec_helper.rb'
describe Game do
before :each do
@new_game=Game.new
end
describe "#new" do
it "creates a new instance of Game" do
describe "#decrease_space" do
it "should start the game with 8 spaces since computer goes first." do
expect(@new_game.decrease_space).to eq(8)
end
it "should decrease @@no_space by 1" do
expect{subject}.to change{@new_game.decrease_space}.by(-1)
end
end
#the method
def welcome
puts "Welcome to a Simpler Tic Tac Toe. The computer will go first."
@board.board["5"]="X"
puts "The computer chose space number 5."
@board.display_board
self.decrease_space
end
def open_spaces(board)
spaces=[]
board.cells.each do |k, v|
spaces << k if board.cells[k]!= "X" && board.cells[k]!="O"
end
spaces
end
def winner?(board)
winning_combos=[[1,2,3], [4,5,6], [7,8,9],
[1,4,7], [2,5,8], [3,6,9],
[1,5,9], [3,5,7]]
human_win=[]
computer_win=[]
board.cells.each do |k,v|
if board.cells[k]=="X"
def game_over?(board)
open_spaces(@board).length <=0 || winner?(@board)
end