state

package
v0.0.0-...-d6d939f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Overview

˅

˅

˅

˅

˅

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppSafe

type AppSafe struct {
	// contains filtered or unexported fields
}

Safe security system that the security status changes with time.

func NewAppSafe

func NewAppSafe() *AppSafe

func (*AppSafe) CallSecurityGuardsRoom

func (a *AppSafe) CallSecurityGuardsRoom(msg string)

Call a security guard room

func (*AppSafe) ChangeState

func (a *AppSafe) ChangeState(state State)

Change state

func (*AppSafe) RecordSecurityLog

func (a *AppSafe) RecordSecurityLog(msg string)

Record security log

func (*AppSafe) SetTime

func (a *AppSafe) SetTime(hour int)

Set time

type Context

type Context interface {
	// Set time
	SetTime(hour int)

	// Change state
	ChangeState(state State)

	// Call a security guard room
	CallSecurityGuardsRoom(msg string)

	// Record security log
	RecordSecurityLog(msg string)
}

type DaytimeState

type DaytimeState struct {
}

func NewDaytimeState

func NewDaytimeState() *DaytimeState

func (*DaytimeState) Alarm

func (d *DaytimeState) Alarm(context Context)

Sound a emergency bell

func (*DaytimeState) Phone

func (d *DaytimeState) Phone(context Context)

Make a normal call

func (*DaytimeState) SetTime

func (d *DaytimeState) SetTime(context Context, hour int)

Set time

func (*DaytimeState) String

func (d *DaytimeState) String() string

func (*DaytimeState) Use

func (d *DaytimeState) Use(context Context)

Use a safe

type NightState

type NightState struct {
}

func NewNightState

func NewNightState() *NightState

func (*NightState) Alarm

func (n *NightState) Alarm(context Context)

Sound a emergency bell

func (*NightState) Phone

func (n *NightState) Phone(context Context)

Make a normal call

func (*NightState) SetTime

func (n *NightState) SetTime(context Context, hour int)

Set time

func (*NightState) String

func (n *NightState) String() string

func (*NightState) Use

func (n *NightState) Use(context Context)

Use a safe

type State

type State interface {
	SetTime(context Context, hour int)

	Use(context Context)

	Alarm(context Context)

	Phone(context Context)

	String() string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL