Bug 260 - The program cannot check the hand of MixSuit if it is not sorted
Summary: The program cannot check the hand of MixSuit if it is not sorted
Status: RESOLVED FIXED
Alias: None
Product: Group3 Mahjong Point Calculator
Classification: Unclassified
Component: System (show other bugs)
Version: 1.0
Hardware: PC Windows
: --- major
Assignee: kakityu6-c
URL:
Depends on:
Blocks:
 
Reported: 2018-11-26 16:56 HKT by CHAN Cheuk Yin
Modified: 2018-11-26 20:09 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description CHAN Cheuk Yin 2018-11-26 16:56:17 HKT
A bug appears in the function checkPattern(Hand hand) of MixSuit.java which the function cannot handle the case of unsorted hand. When checking an unsorted hand pattern of mix suit, the expected output is supposed to be true. However, the actual output is false. 

By tracing the code, a possible reason is that the program takes the first tile as a suit checking tile. As a result, if the suit of the first tile is not character, bamboo or dot, such as red dragon, the program will go to the else statement which returns false.

To resolve the bug, it is suggested to loop through the tile in the hand to find the suit of character, bamboo or dot, then use the suit for checking. If the program cannot find any suit of character, bamboo or dot, return false.
Comment 1 kakityu6-c 2018-11-26 20:09:22 HKT
Thank you for raising the problem. It seems that the problem is caused by unsorted hand and incorrectly assigned variable.

To solve the problem, the program will first enter the loop finding a suit of Character, Bamboo or Dot, rather than choosing the first element in ArrayList<tile> since it is not sorted.

It will be included in the next release(2.0) as a patch, with another possible bug fixing.