Bug 515 - Card value displayed inproperly
Summary: Card value displayed inproperly
Status: RESOLVED FIXED
Alias: None
Product: 2021A-CS3343-Gp17-Big2PokerGame
Classification: Unclassified
Component: Card (show other bugs)
Version: 1.0
Hardware: PC Windows
: High normal
Deadline: 2020-12-04
Assignee: Chung Ka Shing
URL:
Depends on:
Blocks:
 
Reported: 2020-12-04 11:05 HKT by CHAN Tsz Yin
Modified: 2020-12-04 11:25 HKT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description CHAN Tsz Yin 2020-12-04 11:05:15 HKT
When I test the Card class, I found out that the function of return card value always return the wrong result. 

Example 1:
When I new a Card object of card value Diamond-3, I expect the return value function will give me "D3". However, it returns "00".

Example 2:
When I new a Card object of card value Diamond-3, I expect the return value function will give me "C5". However, it returns "12".

Example 3:
When I new a Card object of card value Diamond-3, I expect the return value function will give me "H8". However, it returns "25".

Example 4:
When I new a Card object of card value Diamond-3, I expect the return value function will give me "SQ". However, it returns "39".
Comment 1 CHAN Tsz Yin 2020-12-04 11:13:42 HKT
I estimate it is related to the way how the program get the card suit and card digit value. From my observation, I can see that the pattern of all wrong results are the same. We can either change the way of getting the card suit and card digit value, or create alternative getter to make sure it will convert the value to the information we want.
Comment 2 CHAN Tsz Yin 2020-12-04 11:16:24 HKT
Yes, all of us agree that the problem should be in the way getting card suit and card digit value. However, we do not recommend to change the original getters as they will be called by another class to perform combination comparing and history storing.
Comment 3 CHAN Tsz Yin 2020-12-04 11:20:42 HKT
Okay, then I create two new getters specifically for displaying the card information.

My revised code here, please help me double check if it is correct:

    public String printCardSymbol() {
        return  Character.toString(CARD_SUIT[suit]) + CARD_VALUE[value];
    }
Comment 4 CHAN Tsz Yin 2020-12-04 11:21:21 HKT
Double checked and it works well.