stefilix's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
Members
Active Posts:
24 (0.04 per day)
Joined:
10-April 13
Profile Views:
878
Last Active:
User is offline Sep 15 2013 04:12 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   stefilix has not set their status

Posts I've Made

  1. In Topic: suggest me the best way to write code for a straight hand

    Posted 31 May 2013

    Hi again Baavgai,

    First of all, thanks for this constructive reply, I really appreciate it. I took a quick look at your code, it seems to look clear ;),
    I also notice recursive call at checkStraight() method, which is really great.
    However, I don't have time now to take a deep look at your code, I got to prepare now some stuff for tommorow because I'm going out of town tommorow.
    So, when I get back on the Monday, since I successfully finished the game yesterday, I can then play around with code and to try out if is possible to make up some improvements, before I start a new serious OOP Poker.
    By the way, can I hear your opinion for transience of this code above, besides poor written code?
  2. In Topic: suggest me the best way to write code for a straight hand

    Posted 30 May 2013

    I did now this way:

    mport java.util.Arrays;
    
    public class Testing1 {
    
        public static void main(String[] args) {
            String firstCard = "C4";
            String secondCard = "H5";
            String table[] = {"D2", "D3", "S4", "S1", "C9"};
            int straightPatterns[][] = {{10, 11, 12, 13, 14},
                                        {9, 10, 11, 12, 13},
                                        {8, 9, 10, 11, 12},
                                        {7, 8, 9, 10, 11}, 
                                        {6, 7, 8, 9, 10},
                                        {5, 6, 7, 8, 9},
                                        {4, 5, 6, 7, 8},  
                                        {3, 4, 5, 6, 7},
                                        {2, 3, 4, 5, 6},
                                        {1, 2, 3, 4, 5}};
            
            // constructing hand of seven
            int tempPattern[] = new int[7];
            for (int i = 0; i < 5; i++) {
                tempPattern[i] = Character.getNumericValue(table[i].charAt(1));
            }
            tempPattern[5] = Character.getNumericValue(firstCard.charAt(1));
            tempPattern[6] = Character.getNumericValue(secondCard.charAt(1));
            Arrays.sort(tempPattern);
            
            boolean isStraight = false;
            for (int i = 0; i < straightPatterns.length; i++) {
                System.out.println(Arrays.toString(straightPatterns[i]));
                int count = 0;
                
                for (int j = 0; j < straightPatterns[i].length; j++) {
                    for (int k = 0; k < tempPattern.length; k++) {
                        System.out.print("\t " + straightPatterns[i][j]);
                        System.out.println(" / " + tempPattern[k]);
                        if (straightPatterns[i][j] == tempPattern[k]) {
                            count++;
                            if (count == 5) isStraight = true;
                            System.out.println("");
                            break;
                        } else {
                            continue;
                        }
                    }
                    if (isStraight) break;
                }
                if (isStraight) break;
            }
            System.out.println("Is straight: " + isStraight);                                                                                                         
    
            
        }
    }
    
    


    This seems to me fine, maybe ugly.. but since I'm doing this in case of code practice.
  3. In Topic: suggest me the best way to write code for a straight hand

    Posted 30 May 2013

    I know this is bad OOP practice, but please can you stick to my idea and question above? I think it is isn't a bad idea to play around with indexes, since I'm beginner, and I'm already done this console game 95%.
  4. In Topic: suggest me the best way to write code for a straight hand

    Posted 30 May 2013

    Well, as I said above, I'm using a string length 2 to present card, suit and rank, so for that char I'm going to place card.charAt(1)
  5. In Topic: Does this method really thinks I'm going to cheat him? :D

    Posted 27 May 2013

    oh my god.. my bad... I'm stupid.. Since I'm going to use this methods just in some case for integer compare, then I'm going to return int.. :DD

    public static int getRealPointValue(String pointValue, boolean highAce) {
            switch (pointValue) {
                case "A":
                    return (highAce) ? 14: 1;
                case "K":
                    return 13; 
                case "Q":
                    return 12;
                case "J":
                    return 11;
                case "T":
                    return 10;
                default:
                    return Integer.parseInt(pointValue);
            }
        }
    
    
    


    So now this make sense..
    int pointValue = getRealPointValue("A", true);
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

stefilix hasn't added any friends yet.

Comments

Page 1 of 1
  1. Photo

    jon.kiparsky Icon

    17 Apr 2013 - 12:04
    I appreciate your wanting to help, but let's try more guidance and less of "here's your homework".
Page 1 of 1