Bug 620 - A start move peg's status would change even if the judge function said it to be invalid.
Summary: A start move peg's status would change even if the judge function said it to ...
Status: CONFIRMED
Alias: None
Product: CS3343 Chinese Checker
Classification: Unclassified
Component: Algorithm Component (show other bugs)
Version: unspecified
Hardware: All All
: --- normal
Assignee: yutongmen2-c
URL:
Depends on:
Blocks:
 
Reported: 2021-11-29 11:57 HKT by yutongmen2-c
Modified: 2021-11-29 11:58 HKT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yutongmen2-c 2021-11-29 11:57:30 HKT
Short description:
A start move peg's status would change even if the judge function said it to be invalid.

Steps To Reproduce:
Choose a peg to be the start move at any turn. Then choose an invalid end move position. Check if the start move peg has its status unchanged.

Actual Output:
The start move peg changed its status to 0 (empty flag) even if it did not move at all.

Expected Output:
The start move peg's status would not change.
Comment 1 yutongmen2-c 2021-11-29 11:58:09 HKT
Previous code:

public void giveTips(){
        judge_point.setStatus(0);
        ArrayList<Point> result = new ArrayList<>();
        result = new Judge().find(judge_point, g, 0);

        for (Point point : result) {
            pArray.add(point);
        }
    }

Modified code:

public void giveTips(){
        int prev_status = judge_point.getStatus();

        judge_point.setStatus(0);
        ArrayList<Point> result = new ArrayList<>();
        result = new Judge().find(judge_point, g, 0);

        for (Point point : result) {
            pArray.add(point);
        }
        if(result.isEmpty())    judge_point.setStatus(prev_status);
    }