| Cesar A. K. Grossmann 2004-07-02, 9:24 pm |
| Well, the parser worked pretty well. Now I can concentrate in the
program itself. If somebody has any advice to give, I'm open to suggestions.
I have a file (call it a "database") with two kind of records, one kind
telling the price of the most basic components, and the other describing
a structure made of parts, that can have parts themselves. The idea is
to produce a report telling the cost of all parts that are not basic,
i.e., that are composites.
After coming to a structure to describe the structure, I must be able to
report some errors or flaws:
1. parts that are not described and are not basic components;
2. parts that are described by themselves in any means (circular
definitions, as A is made by A, or A is made by B that is made my A);
3. parts that are described twice (or more times).
I'm still somewhat confused by the problem and the complexity of it. My
first approach is to use a linked list to maintain the basic ("atomic")
itens, and another that maintain the composite itens. All elements of
the composite list will have another small list: the list of its parts.
I can reach that, but I'm not sure how to resolve the 3 flaws above,
that can happen in the "database".
Perhaps I should put in the start of the list the itens that was no
referred by others (i.e., walk in the list, and when you find an item
that uses the item that you currently are trying to insert, then you
must insert it before that one), add a field "total cost of this item"
and resolve it top-down, but how to detect a loop? If I order the list
this way, every item that I reach must be perfectly definible in means
of the itens that precede it in the list. If it is not defined, then I
have a definition missing.
Does someone has a better (and more simple) idea?
TIA
--
..O. Cesar A. K. Grossmann ICQ UIN: 35659423
...O http://www.LinuxByGrossmann.cjb.net/
OOO Quidquid Latine dictum sit, altum viditur
|