/** * Given a deck string, draw a random card from the deck. * You may assume that the deck string is well-formed. * @pa

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
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

Post by answerhappygod »

Given A Deck String Draw A Random Card From The Deck You May Assume That The Deck String Is Well Formed Pa 1
Given A Deck String Draw A Random Card From The Deck You May Assume That The Deck String Is Well Formed Pa 1 (19.13 KiB) Viewed 31 times
/** * 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!
Post Reply