package model

import "fmt"

type Light struct {
	onOffState bool
}

func (l *Light) String() string {
	val := "on"
	if !l.onOffState {
		val = "off"
	}
	return fmt.Sprintf("light is currently %s", val)
}

// NewLight erstellt ein neues Light-Objekt.
func NewLight(onOffState bool) *Light {
	return &Light{onOffState: onOffState}
}

func (l *Light) TurnOn() {
	l.onOffState = true
}

func (l *Light) TurnOff() {
	l.onOffState = false
}

// ToggleState schaltet den Zustand des Lichts um.
func (l *Light) ToggleState() {
	l.onOffState = !l.onOffState
}
