Skip to content

Commit ae85632

Browse files
committed
Added README.md content
1 parent 96d83a8 commit ae85632

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
php-Cards
2+
======================
3+
Small package when in need of french playing cards
4+
and stacks to manage them.
5+
6+
7+
Card
8+
------------------------
9+
10+
Create a Card
11+
```php
12+
$Card = new Card( new Suit::Heart), 1);
13+
```
14+
Get suit of Card
15+
```php
16+
$suit = $Card->getSuit();
17+
```
18+
Get value of Card
19+
```php
20+
$int = $Card->getValue();
21+
```
22+
23+
CardStack
24+
------------------------
25+
26+
**Creating a CardStack**
27+
28+
A CardStack is constructed from an array of Card instances.
29+
```php
30+
$cards = [];
31+
for($i = 1; $i <= 13; ++$i)
32+
$cards[] = new Card( new Suit(Suit::SPADE), $i);
33+
34+
$CardStack = new CardStack($cards);
35+
```
36+
37+
A CardStack can also be constructed without args.
38+
```php
39+
$CardStack = new CardStack; // empty CardStack
40+
```
41+
42+
**Iterating Card's in CardStack, viewing Card.**
43+
44+
A CardStack can be used pretty much as a array.
45+
```php
46+
// single Card
47+
echo $CardStack[3]->getSuit();
48+
// iterate
49+
foreach($CardStack as $Card){
50+
echo $Card->getSuit(), ' ', $Card->getValue();
51+
}
52+
```
53+
54+
The number of Cards in available in CardStack
55+
```php
56+
$count = count($CardStack); // or $CardStack->count()
57+
```
58+
59+
60+
**Manipulating CardStack**
61+
To get and *remove a Card* from the CardStack.
62+
```php
63+
$Card = $CardStack->getTopCard();
64+
$Card2 = $CardStack->getBottomCard();
65+
```
66+
67+
To get and *remove a CardStack* from the stack.
68+
```php
69+
$CardStack2 = $CardStack->getTopStack(3); // get and remove 3 cards
70+
$CardStack3 = $CardStack->getBottomStack(5); // get and remove 3 cards
71+
```
72+
73+
To add a Card to the top or bottom of the CardStack
74+
```php
75+
$CardStack->addOnTop($Card);
76+
$CardStack->addToBottomTop($Card);
77+
```
78+
79+
To add a CardStack to the top or bottom of another CardStack.
80+
The CardStack used as argument will have all of it's Card instances
81+
removed and left empty after the merge.
82+
```php
83+
$CardStack->addStackOnTop($CardStack2); // CardStack2 is now empty
84+
$CardStack->addStackToBottom($CardStack3); // CardStack3 is now empty
85+
```
86+
87+
Split the CardStack in half. The CardStack returned will be the bigger
88+
of the two if unequal.
89+
```php
90+
$CardStack2 = $CardStack->split(); // 15 Cards
91+
$CardStack2->count(); // would return 8
92+
```
93+
94+
Shuffle the stack.
95+
```php
96+
$CardStack->shuffle();
97+
```
98+
99+
Deleting a Card.
100+
```php
101+
unset($CardStack[1]);
102+
```

0 commit comments

Comments
 (0)