C
C#2y ago
Triufelis

❔ Ace value of 1 or 11

I am writing a blackjack game. I have written a method to calculate the amount of "score" the player has. But the method has two separate foreaches. That is not necessarily how a method should be coded. Is there a way to remove one of the foreaches? so it fits the definition of a method?
9 Replies
Angius
Angius2y ago
uh A method can have 69 foreaches nested inside of 420 wheres It's still a method (also, why virtual..?)
Anton
Anton2y ago
looks ok as is
VIPER
VIPER2y ago
Can u not just use an else Oh nvm Ye that’s fine
Tvde1
Tvde12y ago
you could use an else to make it more performant count the number of aces in the one loop and in the second loop, loop for that count
Triufelis
TriufelisOP2y ago
cause its inside an abstarct class. Im just practising all i learn. Putting it all to use. Well at uni, they teach us that there cant be 2 seperate fors or foreaches as that goes agains the principles of OOP. Nested fors and foreaches are good.
Angius
Angius2y ago
They're full of shit, then
Anton
Anton2y ago
what
Angius
Angius2y ago
But no worries Most schools are
Triufelis
TriufelisOP2y ago
Well the logic is that one method should do only one thing Seems unreasonable But it is what it is 🙂
Want results from more Discord servers?
Add your server