Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add moguls subdirectory #10

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
ea06722
Add Blackjack class, Deck class and Dealer class. Add initialize meth…
Jan 12, 2015
8275d34
Edit values for cards. Replace range 1..10 with 1,2,3,4,5,6,7,8,9,10.
Jan 12, 2015
23d42b6
Remove 1 from values. No 1 card in deck.
Jan 12, 2015
045fbc0
Comment out all tests except for setup in order to locate errors.
Jan 12, 2015
20c9429
Run TestBlackjack with two assertions: test_blackjack_exists and test…
Jan 12, 2015
84c638e
Comment out methods that do not have successful tests.
Jan 12, 2015
72bc112
Add test_deck_has_52_cards. Run test.
Jan 12, 2015
30b0a52
Add shuffle method. @shuffled_cards = @cards.shuffle. Add attr_access…
Jan 12, 2015
6f1c2ae
Add test_shuffled_cards_not_equal_to_cards to test whether cards not …
Jan 12, 2015
76af900
Fix math. There are 4 suits. Each suit has 13 cards: 2..10, J=10, Q=1…
Jan 12, 2015
08b43b1
Add Dealer class. Initialize with empty hand and hand_total = 0. Add …
Jan 12, 2015
683d6ca
Add TestDealer class with instance variable @dealer.
Jan 12, 2015
f4896b4
Test dealer_hand_total is equal to 0. Test successful.
Jan 12, 2015
4266c7b
Add attr_accessor :dealer to Blackjack class
Jan 12, 2015
d15e471
Create file code/wolf.rb
Jan 12, 2015
5a69330
Add Koans
Jan 12, 2015
7e20591
Create and commit wolfpack.rb file
Jan 12, 2015
7a76454
Create and commit wolf_test.rb file
Jan 12, 2015
c0b0efa
Create and commit wolfpack_test.rb file
Jan 12, 2015
3303c7b
Create and commit empty code/card.rb file
Jan 12, 2015
3842628
Create and commit empty card_test.rb file
Jan 12, 2015
a327a75
Add attr_accessor for :name, :age. Define initialize
Jan 12, 2015
cb65715
Require minitest/autorun and ./wolf.
Jan 12, 2015
d959fce
Add class Wolfpack. Comment out attr_accessor and initialize.
Jan 12, 2015
c6a1d1d
Add join_pack, howl, howl_louder, submissive_to and dominant_to metho…
Jan 12, 2015
1bbcc29
Test all wolf.rb methods with success.
Jan 12, 2015
ed006f0
Add join_pack method.
Jan 13, 2015
396b048
Add test_wolf_can_join_pack and run tests. 6 Assertions, 0 Errors, O …
Jan 13, 2015
12f4c92
Complete about_array_assignment
Jan 13, 2015
c683238
Complete about_arrays
Jan 13, 2015
3dd00b6
Create file. Add initialize.
Jan 13, 2015
a1516ab
Create test with requiremed files. Add setup
Jan 13, 2015
f784e7e
Add display method
Jan 13, 2015
639c563
complete about_asserts.rb
Jan 13, 2015
862f386
complete about_blocks.rb.
Jan 13, 2015
8403bc7
complete about_class_methods
Jan 13, 2015
d63ab2d
complete about_classes
Jan 13, 2015
e115125
complete about_constants
Jan 13, 2015
6c5aca7
complete path_to_enlightenment through about_symbols
Jan 13, 2015
612da97
Update blackjack.rb.
Jan 14, 2015
c6e3dde
update blackjack_test.rb
Jan 14, 2015
40e27f5
update all so I don't lose changes when I checkout feature/03-Method_…
Jan 14, 2015
d237997
update array methods
Jan 14, 2015
9020be5
add test to factorial.rb
Jan 14, 2015
9bf2834
update num_to_words. should have already been added several branches …
Jan 14, 2015
cd69ae0
no sure what this commit contains
Jan 14, 2015
2f679e0
add moguls subdirectory
Jan 14, 2015
fddf3d1
Merge branch 'feature/05--this-is-only-a-test' of https://github.com/…
Jan 14, 2015
5dff7df
move all wolf related files to /wolf directory
Jan 14, 2015
b070f50
update factorial.rb and num_to_words.rb
Jan 14, 2015
f2287b9
Delete data_types.md
angelabier1 Jan 15, 2015
1c3bae9
having issues
coreres1 Jan 15, 2015
0b24888
clean up repo. update koans from feature/05 branch.
coreres1 Jan 15, 2015
bb59ec1
update repo
coreres1 Jan 15, 2015
b5c61c5
remove data_types.md
coreres1 Jan 15, 2015
3129293
complete examples for Array methoda
coreres1 Jan 15, 2015
1f4d84c
remove methods that do not have examples
coreres1 Jan 15, 2015
eab53b2
create separate file for frequently used methods that do not have exa…
coreres1 Jan 15, 2015
a4d5ef5
add join_pack test
coreres1 Jan 15, 2015
5893514
add join_pack method
coreres1 Jan 15, 2015
9fbd984
edit setup and test_more_than_one_wolf
coreres1 Jan 15, 2015
f7c51c2
edit initialize and more_than_one_wolf methods
coreres1 Jan 15, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 65 additions & 3 deletions code/blackjack.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,69 @@
class Blackjack
attr_accessor :deck #this means we can interact with the instance variable @deck
attr_accessor :deck, :hand, :dealer,:player,:dealt_cards #this means we can interact with the instance variable @deck
# and we can pretend it is a method: Blackjack.new.deck
def initialize #this runs when Blackjack.new is called
@deck = {{ }}
@deck = Deck.new
@dealer = Dealer.new
@player = Player.new
end
end

def deal
@Deck.shuffle.pop
end

def hand
@hand = []
2.times do
@hand = @hand << deck.deal
end
end
end

class Deck
attr_accessor :cards, :shuffled_cards
def initialize
@cards = []

values = [2,3,4,5,6,7,8,9,10,10,10,10,11]

4.times do
values.each do |value|
@cards << value
end
end
end

def shuffle #shuffle cards. ! changes array.
@shuffled_cards = @cards.shuffle!
end

def deal #remove one card from shuffled deck - possible to do yield twice to get two initial cards?
@shuffled_cards.pop
end
end

class Player
attr_accessor :hand_total,:hand
def initialize
@hand = []
@hand_total = 0
end

#def hand
# @hand = @hand << deck.deal
#end

#def bust(hand_total)
# hand_total > 21
#end
end

class Dealer
attr_accessor :hand, :hand_total
def initialize
@hand = []
@hand_total = 0
end

end
#end
90 changes: 73 additions & 17 deletions code/blackjack_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,95 @@
class TestBlackjack < MiniTest::Unit::TestCase
#there's a deck of cards
#there are 52 cards
#there a 4 sets of 14 cards represented by 1-10,J, Q, K, A
#cards 1..10 have the same corresponding values of 1..10.
#there a 4 sets of 13 cards represented by 2-10,J, Q, K, A
#cards 2..10 have the same corresponding values of 2..10.
# J, Q, K each have a value of 10
# A has a value of 11
#Card values: 2,3,4,5,6,7,8,9,10,10,10,10,11 (13 Cards) * 4 Suits = 52 Cards
#there is one dealer
#dealer starts with empty hand
#empty hand equals 0
#there are 1+ player(s)
#the dealer deals a hand to each player and self.
#a hand is 2 random cards from the deck
#each player receives 2 cards from shuffled deck.
# for each player "deal shuffled_cards.pop times 2"
#hand total = 0, deal 2 cards, new hand total = sum of two dealt cards?
#if a player's hand is less than 21, the player is given the option to hit or stay
#if a player stays, the dealer moves to the next player.
#if a player hits, the dealer deals one random card to the player.
#if hand total equals 21, the dealer moves to next player
#if hand total is greater than 21, the player busts
#if hand total is less than 21, the player is given the option to hit or stay.(loop)
#if a player's hand equals 21, the dealer moves to the next player and cards are analyzed.
#the game ends when
#if new hand total equals 21, the dealer moves to next player
#if new hand total is greater than 21, the player busts
#if new hand total is less than 21, the player is given the option to hit or stay.(loop)
#if a player's hand equals 21, player has Blackjack and the dealer moves to the next player.
#Dealer and each Player, play against each other -- compare Dealer's total to Player's total.
#the game ends when there are no cards left in deck?

#class Card
#has a suit and a value
#displaying a card should be a string, like "2 of Hearts" or "King of Spades"
#in blackjack, teh value of jack/queen/king are all 10 and ace is 11


#nouns: deck, dealer, player, hand,
#verbs: deal, hit, stay, shuffle, bust



def setup #this runs before each test
@blackjack = Blackjack.new
end

def test_blackjack_exists
assert Blackjack.new
assert @blackjack
end

def test_deck_exists
assert Blackjack.new.deck
assert @blackjack.deck
end

#def test_deal_method_returns_integer_from_deck
# assert
#end

def test_hand_has_two_cards
assert_equal 2, @blackjack.hand.length
end

end

class TestDeck < MiniTest::Unit::TestCase

def setup
@deck = Blackjack.new.deck
end

=begin
def test_blackjack_deck_has_cards
assert Game.new.grid.is_a? Array
assert_equal Game.new.grid.length, 3
def test_deck_has_52_cards
assert_equal 52, @deck.cards.length
end
=end
end

def test_shuffled_cards_not_equal_to_cards
assert_equal false, @deck.cards == @deck.shuffled_cards
end

end

class TestPlayer < Minitest::Unit::TestCase
def setup
@player = Blackjack.new.player
end

#def test_hand_dealt_has_2_cards
# assert_equal 2, @player.hand.length
#end
end

class TestDealer < MiniTest::Unit::TestCase

def setup
@dealer = Blackjack.new.dealer
end

def test_dealer_hand_total_equal_to_zero
assert_equal true, @dealer.hand_total == 0
end
end

162 changes: 0 additions & 162 deletions code/day_1.rb

This file was deleted.

Loading