GregBrannon's Profile User Rating: *****

Reputation: 2198 Grandmaster
Group:
Expert
Active Posts:
5,231 (3.55 per day)
Joined:
10-September 10
Profile Views:
17,868
Last Active:
User is offline Sep 15 2014 04:51 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Linux
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
Who Cares
Your Car:
Ford
Dream Kudos:
100
Expert In:
Java
Icon   GregBrannon has not set their status

Posts I've Made

  1. In Topic: Tic Tac Toe Java Help

    Posted 2 Aug 2014

    You're using the main() method as a constructor for the class NoughtsAndCrosses. I recommend you build a proper constructor in which the variables are initialized and then eliminate the static variables and methods.

    Once you've cleaned that up, consider the logic you've designed to determine the game's state. Focus on the state of "draw":

    else if (currentState == draw)

    Consider the possible states once the game board has been filled (game over): X wins / Y loses, Y wins / X loses, and draw (neither X nor Y wins or loses). Once you've determined that neither X nor Y have won, then a draw is the default outcome. Of course, X or Y could win before the game board is full, but an early win eliminates the draw as a possible game state.
  2. In Topic: IF statement skipping to else.

    Posted 2 Aug 2014

    Quote

    But I want the program to stop until it receives the user input for 'yesOrNo'.

    I think you mean you want the program to loop until appropriate user input is received. For that, a while() loop would be useful.

    As for your if/else logic flow, I suggest you modify it to be:
    if()
    {
    }
    else if()
    {
    {
    else
    {}
    
  3. In Topic: Extending a static inner class defined within the inheriting class?

    Posted 4 Jul 2014

    The baby in my tummy is my father.
  4. In Topic: Random number panel not working

    Posted 3 Jun 2014

    javajarrett's suggestion is okay, but your problem can be solved by working with ONE JButton called RandomNumber instead of the TWO JButtons called RandomNumber that you currently have. One of the JButtons is declared as a variable with scope through the class, but the other JButton is declared inside the constructor and only has visibility inside the constructor. Due to the limited visibility of the second JButton, the if statement in the the actionPerformed() method can never be true. Well, not the way it's written anyway.

    Remove the JButton declaration from before the RandomNumber on line 16 inside the constructor, and all should be well.
  5. In Topic: Weird Eclipse Errors

    Posted 6 Apr 2014

    Post code that demonstrates the errors. Post the errors.

My Information

Member Title:
D.I.C Lover
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. Photo

    teggr234 Icon

    30 Jun 2014 - 20:52
    Hey greg, will you help me code in java? I know nothing and currently looking for a mentor, I would love to have you mentoring me
  2. Photo

    CoolTech Icon

    24 Feb 2013 - 16:06
    Hi Greg
Page 1 of 1