Jcreator Slot Machine Help!

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

37 Replies - 696 Views - Last Post: 18 May 2014 - 02:20 PM Rate Topic: ***-- 2 Votes

#31 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 564
  • View blog
  • Posts: 2,529
  • Joined: 03-December 12

Re: Jcreator Slot Machine Help!

Posted 18 May 2014 - 02:00 PM

Place this out of your if else statements.

067
    return points


You can change the poi.t value internally and return the after.
Was This Post Helpful? 1
  • +
  • -

#32 Troubles  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 31
  • Joined: 18-May 14

Re: Jcreator Slot Machine Help!

Posted 18 May 2014 - 02:05 PM

its still sayin i need a return statement at line 69
Was This Post Helpful? 0
  • +
  • -

#33 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10390
  • View blog
  • Posts: 38,451
  • Joined: 27-December 08

Re: Jcreator Slot Machine Help!

Posted 18 May 2014 - 02:08 PM

Rather than returning in each if statement, just return after all the if and else-if statements have been evaluated.
Was This Post Helpful? 0
  • +
  • -

#34 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 564
  • View blog
  • Posts: 2,529
  • Joined: 03-December 12

Re: Jcreator Slot Machine Help!

Posted 18 May 2014 - 02:11 PM

You can go two ways. This is one,

Quote

021 public static int winnings(ArrayList<Integer> slotMachine)
022 {
023 int number1= slotMachine.get(0);
024 int number2= slotMachine.get(1);
025 int number3= slotMachine.get(2);
026 int points;
027
028 //if three 7's
029 if (number1==7 && number2==7&& number3==7)
030 {
031 points=750;

033 }
034
035 //if three matches
036 if (number1==number2 && number1==number3 && number2==number3)
037 {
038 points=75;

040
041 }
042
043 //if two matches
044 if(number1==number2 || number1==number3 || number2==number3)
045 {
046 if(number1==7 && number2==7)
047 {
048 points=20;

050 }
051
052 else if (number2==7 && number3==7)
053 {
054 points= 20;

056
057 }
058 }
059 else
060 {
061 points = 5;

063 }
064 return points;
065 }//End of winnings method



The other is

Quote

063 }
064 return 0;
065 }//End of winnings method

This post has been edited by astonecipher: 18 May 2014 - 02:11 PM

Was This Post Helpful? 1
  • +
  • -

#35 Troubles  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 31
  • Joined: 18-May 14

Re: Jcreator Slot Machine Help!

Posted 18 May 2014 - 02:14 PM

View Postmacosxnerd101, on 18 May 2014 - 02:08 PM, said:

Rather than returning in each if statement, just return after all the if and else-if statements have been evaluated.


Okay so now its telling me that the variable points has not been initialized. and thanks
Was This Post Helpful? 0
  • +
  • -

#36 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 564
  • View blog
  • Posts: 2,529
  • Joined: 03-December 12

Re: Jcreator Slot Machine Help!

Posted 18 May 2014 - 02:16 PM

Initialize it to 0 when you declare it.
Was This Post Helpful? 0
  • +
  • -

#37 Troubles  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 31
  • Joined: 18-May 14

Re: Jcreator Slot Machine Help!

Posted 18 May 2014 - 02:18 PM

THAAAANKSS EYERYONNE

anyways i cant thank you all enough ill be sure to give you all reputation points thanks a Billion
to a novice like me this means a lot thanks
Was This Post Helpful? 0
  • +
  • -

#38 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 564
  • View blog
  • Posts: 2,529
  • Joined: 03-December 12

Re: Jcreator Slot Machine Help!

Posted 18 May 2014 - 02:20 PM

DIC is a great place to learn.
Was This Post Helpful? 1
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3