Bug 337

Summary: Program will crash when a pokerHand of TrioX or TrioXX is played
Product: Group 8 (2019) Reporter: LXL <xinlinli7-c>
Component: PlayerAssignee: ZLQ <leqizheng2-c>
Status: RESOLVED FIXED    
Severity: blocker CC: leqizheng2-c, yanglou3-c
Priority: ---    
Version: Version1.0   
Hardware: PC   
OS: Mac OS   

Description LXL 2019-12-04 21:25:20 HKT
When selecting a pokerHand of Trio with kicker and clicking the 'play' button, the program crashed with ConcurrentModificationException. It seems that this error is triggered by the getCardList() method in the TrioBase class.


Expect output: The pokerHand is accepted by table, and game continues.

Actual output: The game was blocked and error message appeared.
Comment 1 ZLQ 2019-12-05 13:00:28 HKT
The problem is caused by:
1. When constructing a poker hand with kickers, it uses .subList() to split the original card list. Therefore, the components are actually different parts of the same ArrayList<Card>. 
2. When invoking getCardList(), it concatenates the kicker to its components, which is equivalent to insert the kickers to the original array list and hence goes wrong.

The problem has been solved, it returns a new array list with the same elements.