Trying to get GUI to print random card in deck using arrayList

后端 未结 3 1370
面向向阳花
面向向阳花 2021-01-17 04:59

So I\'m currently working on a Card War Game in java. I\'m trying to get the GUI screen to print 2 random cards from a set of card images using an arrayList (must use this f

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 05:35

    You could use the Collections.shuffle(...) method to shuffle the ArrayList.

    Then just take the first two entries from the ArrayList.

提交回复
热议问题