I just want a solution to the following exercise on the tour.golang.org
exercise #62.


The exercise is to implement the image interface:

type Image interface {
         // ColorModel returns the Image's color model.
         ColorModel() color <http://golang.org/pkg/image/color/>.Model <http://golang.org/pkg/image/color/#Model>
         // Bounds returns the domain for which At can return non-zero color.
         // The bounds do not necessarily contain the point (0, 0).
         Bounds() Rectangle <http://golang.org/pkg/image/#Rectangle>
         // At returns the color of the pixel at (x, y).
         // At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid.
         // At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.
         At(x, y int <http://golang.org/pkg/builtin/#int>) color <http://golang.org/pkg/image/color/>.Color <http://golang.org/pkg/image/color/#Color>

I'm just learning Go, and I've worked through every exercise except this
one, because
of the different interfaces involved such as Color, Rectangle, etc, I'm
having trouble
with whether or not I should implement every interface involved because
Rectangle, and color.Model etc are interfaces themselves...

I'm obviously not thinking about this the right way. Could someone just
provide one
possible solution so I can study it?

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
groupgolang-nuts @
postedMar 19, '14 at 6:48p
activeMar 19, '14 at 8:31p



site design / logo © 2021 Grokbase