ex08 - Task 3

Beiträge: 158
Registriert: 30. Mär 2011 11:46

ex08 - Task 3

Beitrag von studypad »

Hello, first this part of the exercise:
Create a subclass of Store that implements a Linked List. Its constructor should take an element and the tail of the list. Use
null as the empty tail. Add a second constructor that takes only an element and creates a list with exactly this element. The
implementation should override toString to provide a human readable representation of the list.
Now I'm not sure about the task. Should I implement the class MyStore using a LinkedList or is it just comparison to the LinkedList. I would prefer the way of using MyStore recursively.
Especially because of the following definition in the code:
def +(a: A): Store[A]
For me, it makes sense to implement a recursive "MyStore" and there's no need for a LinkedList.

Beiträge: 99
Registriert: 4. Dez 2010 18:10

Re: ex08 - Task 3

Beitrag von philipp_m »

I'm no tutor but I've understood it like this:
Create a subclass of Store that implements a Linked List.
The important part being "implements a Linked List", not "implements a store as a LinkedList". Therefore I'd say the task is to implement a linked list yourself, not to create a subclass that just uses the LinkedList built into Scala. That would be trivial anyway.

Beiträge: 145
Registriert: 6. Mai 2013 18:04

Re: ex08 - Task 3

Beitrag von svenamann »

Yes, this interpretation is correct. You're supposed to implement a linked list, which is a recursive construct.



Zurück zu „Archiv“