Search:

Type: Posts; User: ineedahero

Page 1 of 3 1 2 3

Search: Search took 0.34 seconds.

  1. [SOLVED] Re: Regarding static variables as global variable in Java....

    Yeah, I tried doing that before and I hit a brick wall.

    I made the Server its own class, and I made the Game its own class, and kept them separate.

    But then I had the Game as a class within the...
  2. [SOLVED] Re: Regarding static variables as global variable in Java....

    Well I would have deleted this topic if I knew how. The formatting of the code is so annoying

    --- Update ---

    Anyways, since you're a mod, couldn't you just delete this topic? I doubt anyone...
  3. [SOLVED] Re: Regarding static variables as global variable in Java....

    What's exactly the point of that? Please don't post in my topic if you aren't going to try to supply an answer.
  4. [SOLVED] Regarding static variables as global variable in Java....

    I kind of want a variable to be global, except you can't do that in Java. I tried making it static instead, but it's still not working when I do that....

    Here's the situation:

    I am making a...
  5. Re: Why isn't my synchronized function acting synchronized?

    Sorry for the confusion.

    run() and processMessage() are both in the player class. The player class implements runnable.

    The player class itself is a part of the server class.

    It seems like...
  6. Why isn't my synchronized function acting synchronized?

    I have a multi-threaded network/client program that plays a game of tic-tac-toe.

    I always begin by asking the client if he's a new or existing player.

    If he's a new player, I ask him what he...
  7. Re: How do I read data from a Random Access File?

    Naw, I don't have any of that.

    I thought Random Access Files took care of everything automatically.

    I'm not even going to both with this stuff then. Thanks for the clarification.
  8. How do I read data from a Random Access File?

    Let's say I have a random access file that holds the names of 1000 students.

    Somewhere in there is a student with the first name "Eli". (assume only one student has the first name Eli).

    Maybe...
  9. Replies
    3
    Views
    122

    Re: Convert int to a bool

    I guess I'm just used to C++ where you could say 'while(integer)'

    I feel like that's cleaner than always saying 'while (integer == 1)'.....
  10. Replies
    3
    Views
    122

    Convert int to a bool

    How do I make this work?



    int i = 0;

    do
    {
    System.out.println("blah blah blah");
    Scanner input = new Scanner(system.in);
  11. Re: When you have a multi-threaded Server and Client program....

    Well....what if the Server sends something, then in the next line of code sends another message.

    Then the client receives the first message....has to do stuff with it...then, when it's done, the...
  12. Re: When you have a multi-threaded Server and Client program....

    I see what you're saying.

    Here, though, the Server is kind of sending two messages in a row.

    I suppose that's bad practice?
  13. Re: When you have a multi-threaded Server and Client program....

    I'm sorry...I don't understand what you mean.

    All I have is the client saying "System.out.println(b.readLine());"

    So, he's waiting for the Server.

    But that's useless if the Server sends the...
  14. Re: When you have a multi-threaded Server and Client program....

    Yes, but the code is kind of complicated. I'll try to give a brief version here.

    The Client is playing a game. He connects to the server, and the server executes the game and gives the client...
  15. When you have a multi-threaded Server and Client program....

    ...how exactly do you ensure that the Server always sends the data after the Client has entered a wait state for the data?

    As in, if I have the Server write something and the Client read something...
  16. Re: How do you add two actionListeners (in a GUI)?

    Ah, so, among the other problems, I have to IMPLEMENT the ActionListener -- not extend it, correct?

    --- Update ---

    Ooohhhh I got it working!!

    What you said was really helpful!!! thanks a lot!
  17. Re: How do you add two actionListeners (in a GUI)?

    Ok so I want to go off your third option!!

    I played around with it in my head for a while and I'm a little confused?

    So I'm thinking it ought to look something like this?


    ...
  18. How do you add two actionListeners (in a GUI)?

    Like, I have one button: submit.

    When I click this button, I take in the data and stuff.

    Then I have a second button: done.

    When I click this button, I close everything down.


    I don't...
  19. Re: Is there a way to clear a java text field in a GUI?

    Yup, that makes sense. Thanks!
  20. Is there a way to clear a java text field in a GUI?

    Let's say the user types something into the JTextField.

    I want to retrieve it.

    I make an action listener, etc, so the user types something in, clicks "submit", and I take in what they wrote...
  21. Re: Run() method of runnable function has no access to data members?

    Ah, stupid mistake.

    Thanks for the help!!!
  22. Re: Run() method of runnable function has no access to data members?

    Well....the variable was the 'board'.

    When I backtrack, I see that the 'board' was set to a 'new Board', thus eliminating its null value.

    I verified this by calling the printBoard method, via...
  23. Run() method of runnable function has no access to data members?

    I'm trying to make a server-client based TicTacToe game, and here I'm just starting off with the raw, raw basics.

    The "client" will be executed in a thread. So, it implements runnable and has a...
  24. Replies
    3
    Views
    113

    Re: Checking memory allocation

    Yeah, I am from C++ lol.

    Thanks for the help guys!
  25. Replies
    3
    Views
    113

    Checking memory allocation

    I need to check that memory was successfully allocated in the following (very, very basic) code. How do I check it? Apparently one option is to use a try....catch block. But what exactly would I be...
Results 1 to 25 of 66
Page 1 of 3 1 2 3