data stucture
-
I am trying to implement a structure that starts with a root class which points to many different nodes. Each node then points to two unique classes. I would like to be able to add nodes and hence the two classes associated with each node. Any help on this would be greatly appreciated. cheers mike
-
I am trying to implement a structure that starts with a root class which points to many different nodes. Each node then points to two unique classes. I would like to be able to add nodes and hence the two classes associated with each node. Any help on this would be greatly appreciated. cheers mike
So you just want a class represenative of your root that contains an array of each unique class?
- Nick Parker Microsoft MVP - Visual C#
My Blog | My Articles -
I am trying to implement a structure that starts with a root class which points to many different nodes. Each node then points to two unique classes. I would like to be able to add nodes and hence the two classes associated with each node. Any help on this would be greatly appreciated. cheers mike
-
So you just want a class represenative of your root that contains an array of each unique class?
- Nick Parker Microsoft MVP - Visual C#
My Blog | My ArticlesI am knew to this coding thing so could you be a bit more specific? I basically want to store "player" data in a struct (i guess) or class. I then want to add struct's or classes to the "player" namely "assesment dates". Attached to each date are two struct's or classes that contain various assesment data. Is that what you thought in the first place? thanks for your response regards mike
-
Something like this?
class RootNode
{
Node[] nodes;
}class Node
{
UniqueNode1 node1 = null;
UniqueNode2 node2 = null;
}Insertion functions, array initialization and all the stuff is left as an exercise :p regards
I am knew to this coding thing so could you be a bit more specific? I basically want to store "player" data in a struct (i guess) or class. I then want to add struct's or classes to the "player" namely "assesment dates". Attached to each date are two struct's or classes that contain various assesment data. Is that what you thought in the first place? thanks for your response regards mike
-
I am knew to this coding thing so could you be a bit more specific? I basically want to store "player" data in a struct (i guess) or class. I then want to add struct's or classes to the "player" namely "assesment dates". Attached to each date are two struct's or classes that contain various assesment data. Is that what you thought in the first place? thanks for your response regards mike
mcrooks wrote:
I basically want to store "player" data in a struct (i guess) or class. I then want to add struct's or classes to the "player" namely "assesment dates". Attached to each date are two struct's or classes that contain various assesment data. Is that what you thought in the first place?
Yes, it's almost the same, but a list will be enough for the players and assesment dates. Something like that:
List<Player> players = new List<Player>();
class Player
{
public name = "Some Name";
public List<AssesmentData> data = new List<AssesmentData>();
}class AssesmentData
{
// object can virtually be anything, can be casted as needed
public object data1 = ...
public object data2 = ...
}You can modify it like that
// create our player
Player player1 = new Player();
player1.name = "Peter Someone";// create two tasks
AssesmentData task1 = new AssesmentData();
task1.data1 = "Some string";
task1.data2 = 50;AssesmentData task2 = new AssesmentData();
task2.data1 = 3.3f
task2.data2 = @"C:\Some\Path";player1.data.Add(task1;
player1.data.Add(task2);players.Add(player1);
regards