factory

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package factory implements the Factory and Abstract Factory design pattern. The interface ParticleFactory declares the abstract factory interface, while FundamentalParticleFactory and CompositeParticleFactory are the specific implementations of this abstract factory, which allows us to produce a simple models that represent untitled fundamental and composite particles of physical world.

Index

Constants

View Source
const (
	MaxCharge = 1
	MinCharge = -1
)

The limits of the charge for the fundamental particles

View Source
const (
	Boson uint16 = iota
	Fermion
	Composite
)

Particles classes enum constants

Variables

This section is empty.

Functions

func Run

func Run()

Types

type CompositeParticleFactory

type CompositeParticleFactory struct{}

CompositeParticleFactory is a simple implementation of a specific factory to create the composite particle. There is no distinguish of a specific particle types here (mesons, baryons, hadrons etc.)

func (*CompositeParticleFactory) Create

func (f *CompositeParticleFactory) Create(spin float32, mass float32, charge int16) (*Particle, error)

type FundamentalParticleFactory

type FundamentalParticleFactory struct{}

FundamentalParticleFactory is the specific factory implementation

func (*FundamentalParticleFactory) Create

func (f *FundamentalParticleFactory) Create(spin float32, mass float32, charge int16) (*Particle, error)

type Particle

type Particle struct {
	Spin   float32
	Mass   float32
	Charge int16
	// contains filtered or unexported fields
}

Particle is the general struct that represents particle model

func (*Particle) AddCharge

func (p *Particle) AddCharge(charge int16) (*Particle, error)

AddCharge is the general interface for the charge assignment of the particle (with validations)

func (*Particle) AddMass

func (p *Particle) AddMass(mass float32) *Particle

AddMass is the general interface for the mass reassignment of the particle

func (*Particle) Class

func (p *Particle) Class() string

Class returns the human readable type of the Particle

func (*Particle) String

func (p *Particle) String() string

String is a stringified representation of the Particle including it's known attributes

type ParticleFactory

type ParticleFactory interface {
	Create(float32, float32, int16) (*Particle, error)
}

ParticleFactory is the abstract factory interface

Jump to

Keyboard shortcuts

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