Discussion:
LinkedList in PolynomialAsLinkedList
(too old to reply)
Jian Li
2004-03-04 03:59:46 UTC
Permalink
From what I see, there are two possible relationships between LinkedList
class and PolynomialAsLinkedList class:

1. PolynomialAsLinkedList owns a member of the LinkedList class
2. PolynomialAsLinkedList extends from the LinkedList class

In class, the notes seem to lean towards 2, but 1 should be okay, too. I
defined a private inner class (so as to not violate the contract) called
Term inside PolynomialAsLinkedList, which is stored as the datum of the
LinkedList class.

Is this okay? Or is 2 mandatory. Thanks in advance.

Jian
Igor Ivkovic
2004-03-04 06:57:18 UTC
Permalink
Post by Jian Li
From what I see, there are two possible relationships between LinkedList
1. PolynomialAsLinkedList owns a member of the LinkedList class
2. PolynomialAsLinkedList extends from the LinkedList class
In class, the notes seem to lean towards 2, but 1 should be okay, too. I
defined a private inner class (so as to not violate the contract) called
Term inside PolynomialAsLinkedList, which is stored as the datum of the
LinkedList class.
Is this okay? Or is 2 mandatory. Thanks in advance.
As long as you meet all of the requirements from the P3 specs, the choice
of how you establish the relationship between PolynomialAsLinkedList and
LinkedList classes is up to you.

What you suggested, to have an attribute of type LinkedList inside of
PolynomialAsLinkedList, seems fine. Also, your idea to have LinkedList
store elements of type Term, where Term is defined as an inner class for
PolynomialAsLinkedList, is also okay.

Igor

Loading...