/** * Given a deck string, draw a random card from the deck. * You may assume that the deck string is well-formed. * @pa
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
/** * Given a deck string, draw a random card from the deck. * You may assume that the deck string is well-formed. * @pa
/** * Given a deck string, draw a random card from the deck. * You may assume that the deck string is well-formed. * @param deck the deck string. * @return a random cardString from the deck. If the deck is empty, return the empty string". * TASK 5 */ public static String drawFromDeck (String deck) { if (deck.equals("")) { return; } else { int deckcardsNum = deck.length() / 2; Random random - new Random(); int i = random.nextInt(deckCardsNum); return deck.substring(2 * i, 2 + 2 * i); )
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!