langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,49 @@
/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
import java.util.List
cards = [String -
'hA', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8', 'h9', 'h10', 'hJ', 'hQ', 'hK' -
, 'cA', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'c10', 'cJ', 'cQ', 'cK' -
, 'dA', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'd10', 'dJ', 'dQ', 'dK' -
, 'sA', 's2', 's3', 's4', 's5', 's6', 's7', 's8', 's9', 's10', 'sJ', 'sQ', 'sK' -
]
cardsLen = cards.length
deck = ArrayList(cardsLen)
loop c_ = 0 to cardsLen - 1
deck.add(String(cards[c_]))
end c_
showHand(deck)
deck = ArrayList shuffle(deck)
showHand(deck)
return
method shuffle(deck = List) public static binary returns List
rn = Random()
dl = deck.size
loop i_ = dl - 1 to 1 by -1
j_ = rn.nextInt(i_)
__ = deck.get(i_)
deck.set(i_, deck.get(j_))
deck.set(j_, __)
end i_
return deck
method showHand(deck = ArrayList) public static binary
dl = deck.size
hl = dl % 4
loop c_ = 0 to dl - 1 by hl
d_ = c_ + hl
if d_ >= dl then d_ = dl
say ArrayList(deck.subList(c_, d_)).toString
end c_
say
return