From edfe4740b8886953fe04a2b8626c7c38cd6dc9d6 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 14 Nov 2023 11:21:21 -0500 Subject: [PATCH] Card suits and initialization finished. --- RoloLudo.package/DeckOfCards.class/class/faceCards.st | 2 +- RoloLudo.package/DeckOfCards.class/class/initialize.st | 9 +++++---- RoloLudo.package/DeckOfCards.class/instance/cards.st | 2 +- RoloLudo.package/DeckOfCards.class/instance/printOn..st | 4 ++++ 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 RoloLudo.package/DeckOfCards.class/instance/printOn..st diff --git a/RoloLudo.package/DeckOfCards.class/class/faceCards.st b/RoloLudo.package/DeckOfCards.class/class/faceCards.st index 987741e..1a3e4d0 100644 --- a/RoloLudo.package/DeckOfCards.class/class/faceCards.st +++ b/RoloLudo.package/DeckOfCards.class/class/faceCards.st @@ -1,3 +1,3 @@ accessing faceCards - ^ #( $J $Q $K) \ No newline at end of file + ^ #( 'J' 'Q' 'K') \ No newline at end of file diff --git a/RoloLudo.package/DeckOfCards.class/class/initialize.st b/RoloLudo.package/DeckOfCards.class/class/initialize.st index 70e53d4..9614ccc 100644 --- a/RoloLudo.package/DeckOfCards.class/class/initialize.st +++ b/RoloLudo.package/DeckOfCards.class/class/initialize.st @@ -2,8 +2,9 @@ accessing initialize | response | response := self new. - self suits do: [:suit | - self numeralCards do: [:number| + self suits keysDo: [:suit | + (self numeralCards, self faceCards) do: [:number| response cards add: number asString, suit. - ] - ]. \ No newline at end of file + ]. + ]. + ^ response \ No newline at end of file diff --git a/RoloLudo.package/DeckOfCards.class/instance/cards.st b/RoloLudo.package/DeckOfCards.class/instance/cards.st index 8341fdf..a762a6b 100644 --- a/RoloLudo.package/DeckOfCards.class/instance/cards.st +++ b/RoloLudo.package/DeckOfCards.class/instance/cards.st @@ -1,3 +1,3 @@ accessing cards - ^ cards \ No newline at end of file + ^ cards ifNil: [ cards := OrderedCollection new] \ No newline at end of file diff --git a/RoloLudo.package/DeckOfCards.class/instance/printOn..st b/RoloLudo.package/DeckOfCards.class/instance/printOn..st new file mode 100644 index 0000000..79e0aec --- /dev/null +++ b/RoloLudo.package/DeckOfCards.class/instance/printOn..st @@ -0,0 +1,4 @@ +accessing +printOn: aStream + super initialize. + ^ aStream nextPutAll: self cards printString \ No newline at end of file