Results 1 to 7 of 7
  1. #1
    jack_nutt is offline Member
    Join Date
    Jun 2011
    Posts
    8
    Rep Power
    0

    Post Flag and data passing

    Hi i need to design a lil thing in java..
    there are 2 points(i have to do for 8 points) in x,y coordinate system.
    When one point wants to send a data lets say "data",it should be sent to point 2 .
    I thought of flag polling,when data needs to be sent , sender point should set it high and the polling sees this then the data appears to other points .

    I need a basic idea as i am new to java.

    thanks

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default

    When one point wants to send
    Please explain what a point is, that it can send data. You defined it as a x,y pair.

    Forget about the x,y stuff.
    Create a class/object that wants to send a message to another class or object.

    sender point should set it high
    What does this mean? "high"???

    There is a long way for you to go with the design of this before you are ready to talk about writing a program.
    What programming languages do you know?

  3. #3
    jack_nutt is offline Member
    Join Date
    Jun 2011
    Posts
    8
    Rep Power
    0

    Default

    Norm,

    i am trying to simulate a network with node(having x,y coordinate as its position) that can send data say string "data" to nodes connected to it.once the other node gets this "data",it should send it to nodes it is connected with .

    i have some basic idea about java classes methods,objects etc. ,and thats why i need a bit of help to get things going like how should i arrange this thing into classes ,would passing data through object be enough etc.

    Looking forward.

    I have worked with C previously.

  4. #4
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default

    What you've described suggests a design for your Node class. Obviously it needs to contain its x,y location. It sounds like it should also contain a Collection of other Nodes to which it is connected. When you put a message into your network, each node that receives it should send it to every other node it is connected to.

    A couple things to think about: nodes should probably not send a message back to the same node from which they received it. And nodes should probably not transmit messages they have already transmitted, should they receive the same message twice.
    Get in the habit of using standard Java naming conventions!

  5. #5
    jack_nutt is offline Member
    Join Date
    Jun 2011
    Posts
    8
    Rep Power
    0

    Default

    Hey

    i jst developed a basic model for finding neighbours.

    the program runs a for loop to generate x,y arrays randomly .
    x[] has x coordinates
    y[] has y coordinates

    of the nodes.

    then using two for loops i calculate the distance between two nodes for each node.
    if the dist< range i want to put the other node in my neigboutlist.

    Since i have the coordinates of a node and its neighbours ,please suggest me how can i store and reference them in an organized way??

  6. #6
    jack_nutt is offline Member
    Join Date
    Jun 2011
    Posts
    8
    Rep Power
    0

    Default

    How can i use class to control my NODE attributes?
    can some one give me some hints

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default

    A big part of using Java is defining classes. There is way too much involved to attempt to type it in here. And I'd do a very poor job of it. You need to find some tutorials and read about OOP and classes.

    Your post showing you were generating two arrays of x and y coordinates shows that you are way off track in designing your program. OOP is different from procedural code which is what you were probably using in C.

    See posts at: http://www.javaprogrammingforums.com...hbourlist.html
    Last edited by Norm; 06-10-2011 at 03:36 AM.

Similar Threads

  1. Passing data between 3 classes
    By tocakt in forum New To Java
    Replies: 3
    Last Post: 04-11-2011, 10:50 PM
  2. Okay..I'm waiving the white flag on this
    By velvetymold in forum New To Java
    Replies: 10
    Last Post: 02-22-2011, 06:15 AM
  3. Passing data between dialogs
    By Wintery in forum New To Java
    Replies: 7
    Last Post: 01-02-2009, 05:35 AM
  4. Need help passing data between classes
    By bri1547 in forum New To Java
    Replies: 3
    Last Post: 07-21-2008, 04:19 AM
  5. Passing data from one JFrame to another
    By abhiN in forum New To Java
    Replies: 2
    Last Post: 03-28-2008, 05:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •