#Problem with Class and calling it as an Iterable.

18 messages · Page 1 of 1 (latest)

blissful bloom
#

On an exercise test it calls the class as an argument (no method or anything, just its variable name), but the expected parameter is Iterable<T>. How does this work? Is there something wrong with the test. The three related code snippets consists of a: Interface Container, an Iterator for that interface, and the class using the interface.

Note: I did try to change the test so the parameter expects a Container and then the class with the interface runs an Iterator method, but I doubt this is the correct solution.

torn lindenBOT
#

This post has been reserved for your question.

Hey @blissful bloom! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

blissful bloom
#

problem occurs in the last method in CardDeckTest.java

olive ledge
#

Most likely, CardContainer should implement Iterable<Card>

#

Ah sorry. Extend. It should extend Iterable<Card>

blissful bloom
#

Hm i see, i've never used Extends before

#

what does it do

#

i've read it has something to do with super

olive ledge
#

It makes the class or interface inherit from the mentioned class or interface

#

In the case of an interface that extends another, it means that implementation of the extending interface, need to implement the methods declared by both interfaces (and any ancestors if there are some)

#

That also means that the extending interface is a subtype of the extended interface

#

So, if CardContainer extends Iterable<Card>, then you may pass a CardContainer where an Iterable<Card> is expected

blissful bloom
#

Holy guacamole.

#

thank you very much

#

this resolved the problem i had

#

ill close the post now