/** Ċ Ġ* Ċ Ġ* ĠThis Ġis Ġchallenge Ġone Ġfor ĠRay w ender lich . com 's ĠAndroid ĠBoot camp Ċ Ġ* ĠSum mer Ġof Ġ 2 0 2 0 Ċ Ġ* ĠWritten Ġby ĠJ enn ifer ĠBa iley Ċ Ġ* Ċ Ġ*/ Ċ Ċ data Ġclass ĠCard ( val Ġsuit : ĠChar , Ġval Ġpip : ĠString ) Ċ Ċ fun Ġmain () Ġ{ ĊĠĠĠ Ġvar Ġdeck Ġ= Ġcreate Deck () ĊĠĠĠ Ġvar Ġhand Ġ= Ġdeal Hand ( 2 , Ġdeck ) ĊĠĠĠ Ġvar Ġtotal Ġ= Ġevaluate Hand ( hand ) ĊĠĠĠ Ġprint Results ( hand , Ġtotal ) Ċ } Ċ Ċ fun Ġcreate Deck (): ĠMutable Set < Card > Ġ{ ĊĠĠĠ Ġvar Ġsu its Ġ= ĠlistOf ('\ u 2 6 6 3 ',' \ u 2 6 6 0 ',' \ u 2 6 6 6 ',' \ u 2 6 6 5 ') ĊĠĠĠ Ġprintln ( su its ) ĊĠĠĠ Ġvar Ġp ips Ġ= ĠlistOf (" 1 "," 2 "," 3 "," 4 "," 5 "," 6 "," 7 "," 8 "," 9 "," 1 0 "," J "," Q "," K ") ĊĠĠĠ Ġvar Ġdeck : ĠMutable Set < Card > Ġ= Ġmutable Set Of () ĊĠĠĠ Ġfor ( suit Ġin Ġsu its ) Ġ{ ĊĠĠĠĠĠĠĠ Ġfor ( pip Ġin Ġp ips ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdeck . add ( Card ( suit , pip )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġdeck Ċ } Ċ Ċ fun Ġdeal Hand ( number : ĠInt , Ġdeck : ĠMutable Set < Card >) Ġ: ĠMutable Set < Card > Ġ{ ĊĠĠĠ Ġvar Ġhand : ĠMutable Set < Card > Ġ= Ġmutable Set Of () ĊĠĠĠ Ġfor ( i Ġin Ġ 0 Ġuntil Ġnumber ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcard Ġ= Ġdeck . random () ĊĠĠĠĠĠĠĠ Ġhand . add ( card ) ĊĠĠĠĠĠĠĠ Ġdeck . remove ( card ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġhand Ċ } Ċ Ċ fun Ġevaluate Hand ( hand : ĠMutable Set < Card >) Ġ: ĠInt Ġ{ ĊĠĠĠ Ġvar Ġtotal Ġ= Ġ 0 ĊĠĠĠ Ġfor ( card Ġin Ġhand ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen ( card . pip ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" K "," Q "," J "," 1 0 " Ġ-> Ġtotal Ġ+= Ġ 1 0 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" A " Ġ-> Ġtotal Ġ+= Ġ 1 1 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġtotal += card . pip . toInt () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġtotal Ċ } Ċ Ċ fun Ġprint Results ( hand Ġ: ĠSet < Card >, Ġtotal : ĠInt ) Ġ{ ĊĠĠĠ Ġprintln (" Your Ġhand Ġwas :") ĊĠĠĠ Ġfor ( card Ġin Ġhand ) Ġ{ ĊĠĠĠĠĠĠĠ Ġprintln ("${ card . pip }${ card . suit }") ĊĠĠĠ Ġ} ĊĠĠĠ Ġprintln (" For Ġa Ġtotal Ġof : Ġ$ total ") Ċ } ĊĊ