Bug 430 - It's found that an invalid move of the Guard is determined to be vaild by the program.
Summary: It's found that an invalid move of the Guard is determined to be vaild by the...
Status: CONFIRMED
Alias: None
Product: CS3343 2020 Group 9_Chinese Chess
Classification: Unclassified
Component: ChessGame (show other bugs)
Version: V2.0
Hardware: PC Windows
: --- enhancement
Deadline: 2020-10-30
Assignee: Marco
URL:
Depends on:
Blocks:
 
Reported: 2020-11-21 22:44 HKT by FENG Yi
Modified: 2020-12-06 23:06 HKT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description FENG Yi 2020-11-21 22:44:55 HKT
Summary: The bug is found when I try to move a Guard chess from (4, 0) to (3, 1). The program prompted that the move is judged valid. However, it is an invalid movement.

Steps to Reproduce:
1. Run the program
2. Input command "new game"
3. Input command "4 0 3 1"

Actual Results:
This move is judged valid and successfully performed. No error message is shown.

Expected Results:
The program prompt "The move you want to make is invalid!"
Comment 1 DUAN Longteng 2020-12-06 23:06:56 HKT
(In reply to FENG Yi from comment #0)
> Summary: The bug is found when I try to move a Guard chess from (4, 0) to
> (3, 1). The program prompted that the move is judged valid. However, it is
> an invalid movement.
> 
> Steps to Reproduce:
> 1. Run the program
> 2. Input command "new game"
> 3. Input command "4 0 3 1"
> 
> Actual Results:
> This move is judged valid and successfully performed. No error message is
> shown.
> 
> Expected Results:
> The program prompt "The move you want to make is invalid!"

The problem is located at getPossibleMove() function in Guard.java. We now add a function checkLegal(int x, int y) to check if a guard is out of bound. The bug is
 resolved.