Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Assignment

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Assignment

    hi there,
    I have to do an assignment, which means putting my car game onto a server/client. I think I am going to do it using serialization and the TCP server/client way. I've made the game, and I've practised using seralization but I don't quite know how to put the two together. For example, I will have the race track drawn onto the server but how do you put this together?

    Part of the TCP Server code:

    public void run()
    	{
    		try
    		{
    			while (true)
    			{
    				Integer mes = (Integer)m_in.readObject();
    				System.out.println("Server::Integer read");
    				m_out.writeObject(new Car(mes, mes));
    				System.out.println("Server::Object written");
    			}
    		}
    		catch (EOFException e)
    		{
    			System.out.println("EOF :" + e);
    		}

    Would it be in here? as a paint Component? or do you join it to another class that currently has the race track in..
    any hints/tips as to joining the two together would be great thanks


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Assignment

    Not quite sure what you are asking...do you want to know where the GUI drawing should go? You should send only the necessary objects to the client, and drawing should in most cases run on the client.

  3. The Following User Says Thank You to copeg For This Useful Post:

    Polly2010 (November 30th, 2010)

  4. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Assignment

    Can I call the class that I did my GUI drawing in from the client? I made my game as a thread..

  5. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Assignment

    Quote Originally Posted by Polly2010 View Post
    Can I call the class that I did my GUI drawing in from the client? I made my game as a thread..
    I am not sure what you mean. Is that class on the server? Than yes, but you must serialize said class between the client/server. Like I mentioned above (and again I don't know if this addresses your issue because I am still unsure what the question is) do the drawing on the client, pass changes to said gui for drawing between client/server. Passing the whole darn thing is in most cases passing redundant information and chews up bandwidth.

Similar Threads

  1. Help with assignment
    By NPVinny in forum What's Wrong With My Code?
    Replies: 12
    Last Post: July 3rd, 2010, 05:31 PM
  2. please help me in my assignment :(
    By asdfg in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 18th, 2010, 07:59 AM
  3. need help on an assignment :(
    By gamfreak in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 23rd, 2010, 04:20 PM
  4. Replies: 1
    Last Post: February 22nd, 2010, 08:20 AM
  5. Need help with assignment
    By TonyL in forum Loops & Control Statements
    Replies: 2
    Last Post: February 20th, 2010, 09:44 PM