package main

import (
	"fmt"
	"time"
)

type Person struct {
	lastName  string
	firstName string
	dob       time.Time
}

type Student struct {
	Person
	studentId int
}

type Instructor struct {
	Person
	employeeId int
}

func main() {
	s := Student{Person{"Joe", "Smith",
		time.Date(1995, 4, 7, 0, 0, 0, 0, time.UTC)}, 101}
	e := Instructor{Person{"Jane", "Doe",
		time.Date(1961, 12, 24, 0, 0, 0, 0, time.UTC)}, 313}

	s.print()
	s.age()
	fmt.Println()

	e.print()
	e.age()
	fmt.Println()

}

func (p *Person) print() {
	fmt.Printf("%s, %s", p.lastName, p.firstName)
}

func (s *Student) print() {
	s.Person.print()
	fmt.Printf(": %d ", s.studentId)
}

func (e *Instructor) print() {
	e.Person.print()
	fmt.Printf(": %d ", e.employeeId)
}

func (p *Person) age() {
	t := time.Now()
	if t.Month() < p.dob.Month() {
		fmt.Printf("Age: %3d", t.Year()-p.dob.Year()-1)
	} else {
		fmt.Printf("Age: %3d", t.Year()-p.dob.Year())
	}
}
