[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [ajug-members]: Logic Assistance



The reason I used the 01.00.01.00 example was becuase in your list below, you have an entry for
02.00.01.00.  Perhaps this was a mistake?

I think I follow your logic below, but I'm not 100%.  If it is true that all children must
increment the next zero position of their parent when created, then the logic could look like the
following for inserting a node "Above" the current node:

1. For current selection, find the last non zero position.  (For 01.01.00.00, this would be
position 2).
2. The parent of this node would have to be the node with a zero in this position and all
positions after it. (01.00.00.00)
3. The children of the parent node would have to be any node that had all the non-zero positions
of the parent node (position 1 equals 01, so 01.02.00.00 or 01.01.01.00 for example).
4. For all chidren whose value in the important position (the 2nd position in our example) is
greater than, or equal to, the given value in the selected node (01 in our example), increment
this and only this position (so 01.02.00.00 would become 01.03.00.00 and 01.01.01.00 would become
01.02.01.00)
5. Assign the current selections value to the new node (01.01.00.00)

WM


--- Tom Boyce <tom.boyce@wellfound.com> wrote:
> It is!  but to getParent, you have to figure out what is the parent!  Any
> code can be a parent, but it has to be sequential.  01.00.01.00 I don't
> think can exist.  Once a position is given a value > 0 the next position
> following must be incremented before any other position can be.  Each time
> you move over a position, it becomes a child of the previous one.  If you
> just increment the last position with a value > 0, it is a "sibling" of the
> one above.  So, if I assign the new entry with selected code, the selected
> entries last position with a value > 0 is incremented by 1, then the next
> value must be evaluated for the last position being equal to the current.
> If equal, increment by one, if not stop.
> 
> This sounds right, but am I missing something??????????
> 
> Tom
> 
> -----Original Message-----
> From: Webb Morris [mailto:webbmorris@yahoo.com] 
> Sent: Friday, May 14, 2004 3:00 PM
> To: ajug-members@ajug.org
> Subject: Re: [ajug-members]: Logic Assistance
> 
> 
> This seems to be an awful way to specify a parent-child relationship.  I
> mean is 01.00.01.00 a new parent node or is it a child of 01.00.00.00?  If
> it is a child, does it come before or after 01.01.00.00? The mind bogles.
> 
> Anyway, it seems that the logic would look something like the following:
> 
> 1 - For selected element, call getParent
> 2 - For parent element, call getAllChildren
> 3 - Iterate over list
> 4 - If child id >= selected element's id, increment id by 1
> 5 - set new child's id to selected element's old id
> 
> Hope this helps,
> 
> WM
> 
> 
> --- Tom Boyce <tom.boyce@wellfound.com> wrote:
> > Hello all,
> > 
> > I am working on a project which, in part, adds a new item to the 
> > database. One of the columns is a code in the following format:
> > 					00.00.00.00
> > 
> > These codes can represent parent or child elements as follows:
> > 
> > 					01.00.00.00    Parent
> > 					01.01.00.00	   Child
> > 					01.02.00.00    Child
> >   					01.03.00.00	   Child
> > 					02.00.01.00    Parent
> > 					02.00.01.01    Child
> > 
> > Almost any code can be a parent where if it can be subdivided.
> > 
> > When the user adds a new item, they can select one of 3 radio buttons: 
> > Add Above, Add Below or As Child. This will add the item relative to 
> > the code they select in a list box. Using one of the above examples, 
> > if they select the second item and Add Above, the new item takes on 
> > the Code of the item selected and all subsequent codes within that 
> > category need to be re-sequenced one number higher.
> > 
> > So far, I am getting the selection the user made and breaking it into 
> > 4 variables parsed to an int by a StringTokenizer.  Also, for the 
> > "Above" radiobutton, I am just assigning the selected code to the new 
> > item.  Where I am struggling is in developing the logic to create a 
> > new code for the one selected as well as figuring which ones to 
> > re-sequence and how.  On the surface, it seems pretty straightforward, 
> > but as I try to write even the pseudo code for the logic, it makes me 
> > appreciate what the AI folks go through to make software try to mimic 
> > human thought!
> > 
> > Anyone have any suggestions?
> > 
> > 
> > 
> > Tom Boyce
> > Software Engineer
> > WellFound Technologies, Inc
> > 770.424.4645 ext 105
> > 
> > *****NOTICE*****
> > This electronic mail transmission may contain confidential information 
> > and is intended only for the person(s) named.  Any use, copying, or 
> > disclosure by any other person is strictly prohibited.  If you have 
> > received this transmission in error, please notify the sender 
> > immediately via e-mail, and delete it from your computer.  Although 
> > this e-mail and any attachments are believed to be free of any virus 
> > or other defect that might negatively affect any computer system into 
> > which it is received and opened, it is the responsibility of the 
> > recipient to ensure that it is virus free and no responsibility is 
> > accepted by WellFound Technology, Inc. or the sender for any loss or 
> > damage arising in any way in the event that such a virus or defect 
> > exist.
> >  
> > 
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.679 / Virus Database: 441 - Release Date: 5/7/2004
> >  
> > 
> 
> 
> 
> 	
> 		
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! - Internet access at a great low price.
> http://promo.yahoo.com/sbc/
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.679 / Virus Database: 441 - Release Date: 5/7/2004
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.679 / Virus Database: 441 - Release Date: 5/7/2004
>  
> 



	
		
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/