Bug 609 - Need to handle when discard pile and deck are empty
Summary: Need to handle when discard pile and deck are empty
Status: CONFIRMED
Alias: None
Product: UNO Game
Classification: Unclassified
Component: DeckManager (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- enhancement
Assignee: zen268zzsyc
URL:
Depends on:
Blocks:
 
Reported: 2021-11-24 21:45 HKT by abbyshek2-c
Modified: 2021-11-24 21:45 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 abbyshek2-c 2021-11-24 21:45:54 HKT
Currently, the game will refill the deck with the discard pile. 

However, if all the player do not play card and keep drawing card, there are will

be case that both discard pile and deck are empty. Error occur as no card can be 

refilled.

Should modify the code the handle this case.

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

Exception in thread "main" java.util.NoSuchElementException
at java.base/java.util.ArrayDeque.removeFirst(ArrayDeque.java:362)
at java.base/java.util.ArrayDeque.pop(ArrayDeque.java:593)
at com.cs3343.gp15.game.DeckManager.DrawCard(DeckManager.java:68)
at com.cs3343.gp15.game.GameManager.playerDrawCard(GameManager.java:162)
at com.cs3343.gp15.game.GameManager.drawProcess(GameManager.java:103)
at com.cs3343.gp15.game.GameManager.computerTurn(GameManager.java:115)
at com.cs3343.gp15.game.GameManager.playerAction(GameManager.java:74)
at com.cs3343.gp15.game.GameManager.gameProcess(GameManager.java:47)
at com.cs3343.gp15.game.Main.main(Main.java:13)