Bug 778 - Need to handle card value input format errors
Summary: Need to handle card value input format errors
Status: CONFIRMED
Alias: None
Product: 2023A CS3343 Group 33 Project
Classification: Unclassified
Component: HumanStrategy (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- major
Assignee: chris li
URL:
Depends on:
Blocks:
 
Reported: 2023-11-13 11:18 HKT by chris li
Modified: 2023-11-13 11:18 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 chris li 2023-11-13 11:18:16 HKT
Currently, the game requires a user to input card value. 

However, if the user input wrong format like "0" or "Blue", then the game will be crashed, because input[1] does not exist in new Card(input[0], input[1]).

Should modify the code the handle this case.

-----------------------------------------------------------------

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at Strategic.HumanStrategy.chooseCards(HumanStrategy.java:40)
	at Player.Player.executeStrategy(Player.java:81)
	at GameManager.GameManager.startTurn(GameManager.java:87)
	at Main.main(Main.java:59)