package main

import (
	"fmt"
	"golang.source-fellows.com/pattern/strategy/pkg/functional"
	"golang.source-fellows.com/pattern/strategy/pkg/hierarchie"
)

func main() {
	fmt.Println("Payment Strategy")

	shoppingCard := hierarchie.ShoppingCard{}
	shoppingCard.SetStrategy(&hierarchie.CreditCardPayment{})

	item1 := hierarchie.Item{}

	shoppingCard.AddItem(item1)
	err := shoppingCard.Pay()
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("everything payed")

	item2 := functional.Item{}

	fShoppingCard := functional.ShoppingCard{}
	fShoppingCard.SetStrategy(functional.CreditCardPayment)
	fShoppingCard.AddItem(item2)
	err = fShoppingCard.Pay()
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("everything payed")

}
