James Carman, President<br />Carman Consulting, Inc.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Well, try writing a parameter that encompases both value and suit. Say 1-52. Divide the parameter by 13.0 and take the ceiling of that -- there's your suit. (Math.ceil(1/13.0) == 1.0, Math.ceil(13/13.0) == 1.0, Math.ceil(14/13.0) == 2.0).
Then use the modulus operator to get the value. 1%13 == 1, 14%13 == 1 (Both aces), but 13%13 == 0! You would either need an if statement or some more obtuse math, like ((n-1)%13)+1, which would give you the value you seek.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
James Carman, President<br />Carman Consulting, Inc.
While this may seem overly picky, keep in mind that the professor may be testing this using a program of their own that will simply mark wrong the line that says "Deuce" when it expects "two".Originally posted by Joel McNary:
Double check. Some teachers/professors might take off for the fact that "two" was specified in the instructions, while you have "Deuce." If you go with "Deuce", why not use "Trey" instead of three? If they're really picky, you might be taken off for the fact that lowercase was specified, but you've used capitalized your values and suits.
Yes, that was a bit nebulous, since all arrays in Java are zero-based.Originally posted by Kev Peterson:
could you please give a small example David, cause I understand the idea of having a zero based array but could you please show me how to impeliment that?
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|