Loading an int return into an array

Loading one of multiple return values into an array

Page 1 of 1

3 Replies - 765 Views - Last Post: 02 April 2010 - 02:43 AM Rate Topic: -----

#1 SuckMyBookah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 27-March 10

Loading an int return into an array

Posted 01 April 2010 - 12:38 AM

Hey guys i guess i should show you my code and tell you want I'm having trouble with:

IE : I'm making poker:


 int returnHandValue(){
        
        if (RoyalFlush() == true){
            System.out.println("RoyalFlush");
            return 9;
        }else if (StraightFlush() == true){
            System.out.println("StraightFlush");
            return 8;
        }else if (FourKind() == true){
            System.out.println("Four Kind");
            return 7;
        }else if (FullHouse() == true){
            System.out.println("Full house");
            return 6;
        }else if (Flush() == true){
            System.out.println("Flush");
            return 5;
        }else if (Straight() == true){
            System.out.println("Straight");
            return 4;
        }else if (Triples() == true){
            System.out.println("Triples");
            return 3;
        }else if (TwoPair()== true){
            System.out.println("TwoPair");
            return 2;
        }else if (Pair() == true){
            System.out.println("Pair");
            return 1;
        }else{
            System.out.println("Nothing");
            return 0;
            
        }
        
    }


EDIT: Inserted code tags, PennyBoki. Please :code: in future. Thanks. :)

So we got this method and it will return a value to another part of my code and is all i want the return value to do is load into an array when it returns. Lets say my array is called handValues[i] how do i make handValues[i] become the value of return??


Hope you understand what I'm talking about

Thanks Brad.

This post has been edited by PennyBoki: 01 April 2010 - 01:41 AM
Reason for edit:: code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Loading an int return into an array

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Loading an int return into an array

Posted 01 April 2010 - 03:08 AM

If I understand what you are asking...

handValues[i] = returnHandValue();


Was This Post Helpful? 0
  • +
  • -

#3 Mercia Labs  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 25
  • Joined: 18-February 10

Re: Loading an int return into an array

Posted 01 April 2010 - 05:07 AM

Also you can simplify all those ifs eg
 if (RoyalFlush() == true){
..


could be just
 if (RoyalFlush()){



since (I guess) RoyalFlush() returns a boolean.
BTW only classes and interfaces start with capital letters - so the methods should be named
royalFlush()
and so on.
Was This Post Helpful? 1
  • +
  • -

#4 SuckMyBookah  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 27-March 10

Re: Loading an int return into an array

Posted 02 April 2010 - 02:43 AM

Thanks for the help guys!!!

Mercia the simplifying was much help. Im still having trouble with the array but ill work it out. I think i may have my methods in the wrong class or something like that
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1