package main

import "fmt"

// section: embedded
// Employee has two methods that call each other
type Employee struct {
	Name string
}

func (e Employee) Greet() {
	fmt.Printf("Hello, I'm ")
	e.Introduce() // calls Employee.Introduce, NOT Manager.Introduce
}

func (e Employee) Introduce() {
	fmt.Println(e.Name)
}

// section: embedded

// section: outer
// Manager embeds Employee and tries to "override" Introduce
type Manager struct {
	Employee
	Department string
}

// This method is NEVER called from Greet()!
func (m Manager) Introduce() {
	fmt.Printf("%s, Manager of %s\n", m.Name, m.Department)
}

// section: outer

// section: main
func main() {
	m := Manager{
		Employee:   Employee{Name: "Alice"},
		Department: "Engineering",
	}

	// Calling Introduce directly works as expected
	fmt.Print("Direct call: ")
	m.Introduce() // Output: Alice, Manager of Engineering

	// But calling Greet uses Employee.Introduce, not Manager.Introduce!
	fmt.Print("Via Greet:   ")
	m.Greet() // Output: Hello, I'm Alice (NOT "Alice, Manager of Engineering")
}

// section: main
