package main

import (
	"fmt"
	"golang.source-fellows.com/pattern/iterator/internal"
)

func main() {
	fmt.Println("Iterator Sample")

	//init Collection
	dbCol := &internal.CustomerDBCollection{}
	dbCol.AddCustomer(internal.Customer{
		EMail:     "kristian@source-fellows.com",
		Interests: []string{"Cloud"},
	})
	dbCol.AddCustomer(internal.Customer{
		EMail:     "luis@source-fellows.com",
		Interests: []string{"Cloud"},
	})
	dbCol.AddCustomer(internal.Customer{
		EMail:     "theo@source-fellows.com",
		Interests: []string{"Cloud"},
	})

	//use Collection as CustomerCollection
	var col internal.CustomerCollection = dbCol
	sender := internal.EMailSender{}
	iter := col.CreateCloudInterestedCustomerIterator()

	for iter.Next() != nil {
		sender.SendEMail(iter.CurrentItem(), "cloud-template")
	}

	fmt.Println(iter.IsDone())

}
