Ejemplo n.º 1
0
func New(o Object) *Imp {
	//
	x := new(Imp)
	switch o.(type) {
	case *enum.Imp:
		x.Object, x.typ = enum.New(enum.Enum(o.(*enum.Imp).Typ())), Enumerator
	case *tval.Imp:
		x.Object, x.typ = tval.New(), TruthValue
	case *char.Imp:
		x.Object, x.typ = char.New(), Character
	case *text.Imp:
		x.Object, x.typ = text.New(o.(*text.Imp).Len()), Text
	case *bnat.Imp:
		x.Object, x.typ = bnat.New(o.(*bnat.Imp).Startval()), Natural
	case *breal.Imp:
		x.Object, x.typ = breal.New(4), Real
	case *clk.Imp:
		x.Object, x.typ = clk.New(), Clocktime
	case *day.Imp:
		x.Object, x.typ = day.New(), Calendarday
	case *euro.Imp:
		x.Object, x.typ = euro.New(), Euro
	case *cntry.Imp:
		x.Object, x.typ = cntry.New(), Country
	case *pers.Imp:
		x.Object, x.typ = pers.New(), Person
	case *phone.Imp:
		x.Object, x.typ = phone.New(), PhoneNumber
	case *addr.Imp:
		x.Object, x.typ = addr.New(), Address
	default:
		ker.Panic("atom.New: parameter does not characterize an atom.Atomtype")
	}
	return x
}
Ejemplo n.º 2
0
func New() *Imp {
	//
	x := new(Imp)
	x.Imp = euro.New()
	x.Imp.Set2(0, 0)
	x.pos = sync.NewCond(&x.mE)
	return x
}
Ejemplo n.º 3
0
func Selected(l, c uint) *Imp {
	//
	cF, cH := col.ScreenF, col.ScreenB
	col.Contrast(&cH)
	n := uint(0)
	z, s := scr.MousePos()
	x := new(Imp)
	sel.Select1(name, uint(NAtomtypes), M, &n, z, s, cF, cH)
	if n < uint(NAtomtypes) {
		x.typ = Atomtype(n)
	} else {
		return nil
	}
	switch x.typ {
	case Enumerator:
		e := enum.Title // TODO e per select-menue aussuchen
		x.Object = enum.New(e)
	case TruthValue:
		x.Object = tval.New()
	case Character:
		x.Object = char.New()
	case Text:
		n := uint(10) // TODO n editieren
		x.Object = text.New(n)
	case Natural:
		n := uint(10) // TODO n editieren
		x.Object = bnat.New(n)
	case Real:
		n := uint(6) // TODO n editieren
		x.Object = breal.New(n)
	case Clocktime:
		x.Object = clk.New()
	case Calendarday:
		x.Object = day.New()
	case Euro:
		x.Object = euro.New()
	case Country:
		x.Object = cntry.New()
	case Person:
		x.Object = pers.New()
	case PhoneNumber:
		x.Object = phone.New()
	case Address:
		x.Object = addr.New()
	}
	return New(x)
}
Ejemplo n.º 4
0
func NewMon() *ImpMon {
	//
	x := new(ImpMon)
	x.balance = euro.New()
	x.balance.Set2(0, 0)
	p := func(a Any, i uint) bool {
		if i == 1 { // draw
			return a.(*euro.Imp).Eq(x.balance) || a.(*euro.Imp).Less(x.balance)
		}
		return true // deposit
	}
	f := func(a Any, i uint) Any {
		if i == 0 { // deposit
			x.balance.Plus(a.(*euro.Imp))
		} else { // draw
			x.balance.Minus(a.(*euro.Imp))
		}
		return x.balance
	}
	x.Imp = mon.NewC(2, f, p)
	return x
}
Ejemplo n.º 5
0
func NewF(s string, p uint) *ImpF {
	//
	x := new(ImpF)
	balance := euro.New()
	balance.Set2(0, 0)
	c := func(a Any, i uint) bool {
		if i == 1 { // draw
			return a.(*euro.Imp).Eq(balance) || a.(*euro.Imp).Less(balance)
		}
		return true // deposit
	}
	f := func(a Any, i uint) Any {
		balance.Write(0, 0)
		if i == 0 { // deposit
			balance.Plus(a.(*euro.Imp))
		} else { // draw
			balance.Minus(a.(*euro.Imp))
		}
		balance.Write(1, 0)
		return balance
	}
	x.Imp = fmon.New(balance, 2, f, c, s, p)
	return x
}