Results 1 to 7 of 7
Thread: Flag and data passing
- 06-06-2011, 08:52 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 8
- Rep Power
- 0
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
- 06-06-2011, 11:38 PM #2
Please explain what a point is, that it can send data. You defined it as a x,y pair.When one point wants to send
Forget about the x,y stuff.
Create a class/object that wants to send a message to another class or object.
What does this mean? "high"???sender point should set it 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?
- 06-07-2011, 05:54 AM #3
Member
- Join Date
- Jun 2011
- Posts
- 8
- Rep Power
- 0
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.
- 06-07-2011, 09:24 AM #4
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!
- 06-09-2011, 01:18 AM #5
Member
- Join Date
- Jun 2011
- Posts
- 8
- Rep Power
- 0
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??
- 06-09-2011, 01:20 AM #6
Member
- Join Date
- Jun 2011
- Posts
- 8
- Rep Power
- 0
How can i use class to control my NODE attributes?
can some one give me some hints
- 06-10-2011, 01:31 AM #7
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.htmlLast edited by Norm; 06-10-2011 at 03:36 AM.
Similar Threads
-
Passing data between 3 classes
By tocakt in forum New To JavaReplies: 3Last Post: 04-11-2011, 10:50 PM -
Okay..I'm waiving the white flag on this
By velvetymold in forum New To JavaReplies: 10Last Post: 02-22-2011, 06:15 AM -
Passing data between dialogs
By Wintery in forum New To JavaReplies: 7Last Post: 01-02-2009, 05:35 AM -
Need help passing data between classes
By bri1547 in forum New To JavaReplies: 3Last Post: 07-21-2008, 04:19 AM -
Passing data from one JFrame to another
By abhiN in forum New To JavaReplies: 2Last Post: 03-28-2008, 05:39 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks