The Artima Developer Community
Sponsored Link

Java Answers Forum
Some problems... ( in realisiering of an idea )

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Draganka Tusheva

Posts: 8
Nickname: tusheva
Registered: Aug, 2003

Some problems... ( in realisiering of an idea ) Posted: Aug 18, 2003 6:37 AM
Reply to this message Reply
Advertisement
So i will try to fully explain a program that I am writing and an idea for the implementation that i can not get to the end... So ... I must make a search from annotations. So i have a forum where people post there opinions. every opinion has a weight ( it can be computed depending on the type of the opinion by a given formula implemented in a calculate method )This weight can be interpreted as a probability so that the values should be between 0 and 1 (some statistical methods are used).So i have implemented the different relations so to say between opinions with different classes.Every class represents a different relation.because all the classes share common behaviour i have created an interface with the following constants and methods as a part of it.

public static final String RELATIONTYPE=null;
public static final String sourceID=null;
public static final String destinationID=null;
public float calculateWeight();
public void setSourceWeight(float sourceWeight);
public void setDestinationWeight(float destinationWeight);
public float getSourceWeight();
public float getDestinationWeight();
public String getRelationType();
public String getSourceID();
public String getDestinationID();
public void setSourceID(String sourceID);
public void setDestinationID(String destinationID);

So far so good. Now every class implements the so defined interface.( the name is Relation )As parameters for the constructors of the classes we take
float sourceWeight, float destinationWeight,String sourceID,String destinationID

The classes are as follows:Analogy,Cause,Backgroundinformation,Couterargument,Interpretation,Elabo ration,SupportArgument,Relation..
As I have mentioned they represent different relations with a sourceID and DestinationID... You can imagine it as a tree that consists of twigs represented by an instance of any of the classes.

As I wanted to search in the tree so to say i come up with an idea to make a hash table that wíll be the following...
As a key i want to take the sourceID and as a value a vector that will retrieve the instances that have the same SourceID.For example let for one instance a sourceID be "A" and a destinationID be "B". Let we have another insctance with say SourceID "A" and destinationID "C".. Well now the vector should consist of the two relations i.e the two instances of the classes that implement Ralation.( the interface ).. And so on...
Now here comes my problem...I can make the hash table so to say when i just have one Relation r for example as a parameter for a method that i want to write...
But that is not what the program should be able to do. It should be somehow dynamic and should somehow read all of the created instances then create a hashtable which will consists of a sourceID as a key and a value as a vector that will consists of all objects with the keyed sourceID.....
I have made a code for instance but still it does not help..
I was thinking of crating a global vector that will at the beginning contain all the created instances. For example I will define it in Relation ( the interface ) and then I will use the add command in every constructor of my classes.
Can i for example have this type of code:

In Relation:
public static Vector all = new Vector();

And then in every constructor of all the classes:
all.add(this);

Then if i could do this i can read parts of the vector by using a loop on i from 1 to all.size() ( or something that will somehow tell me how many objects are there in all ).But I still got messed up with all the comaparison stuff as a want to make these vectors that will correspond to every different souurceID. So I am completely confused as I do not have a better idea.I don,t want to use a tree structure because I am not supposed to.
So if anyone could help me please send an answer to me or I will appreciate any ideas. Because after that i can write methods that will easily find the things that i need. But not until i can not create this structure of the things that i have written for..
I will be very glad to get some help...
Sincerely,Gery

Topic: "Ant" past exam question - help needed!! Previous Topic   Next Topic Topic: java programing

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use