예제 #1
0
파일: imp.go 프로젝트: CaptainSoOmA/Uni
// Aktuelle Ecke ist (L1, n1), postaktuelle Ecke ist (L, n).
func edge1(l Linie, n uint, l1 Linie, n1, t uint, direkt bool) {
	//
	if netz.ExPred2(func(a Any) bool { b := a.(*bahnhof.Imp); return b.Linie() == l && b.Nummer() == n },
		func(a1 Any) bool { b1 := a1.(*bahnhof.Imp); return b1.Linie() == l1 && b1.Nummer() == n1 }) {
		b, b1 := netz.Get2()
		bhf, bhf1 := b.(*bahnhof.Imp), b1.(*bahnhof.Imp)
		bhf.Umstieg()
		bhf1.Umstieg()
		netz.Put2(bhf, bhf1)
		if direkt {
			l = bhf.Linie()
		} else {
			l = Fußweg
		}
		_gleis.Def(l, t)
		netz.Edge1(_gleis)
	} else {
		if !netz.ExPred(func(a Any) bool { b := a.(*bahnhof.Imp); return b.Linie() == l && b.Nummer() == n }) {
			errh.Error2("fehlt Linie", uint(l), "Bhf", n)
		}
		if !netz.ExPred(func(a Any) bool { b := a.(*bahnhof.Imp); return b.Linie() == l1 && b.Nummer() == n1 }) {
			errh.Error2("fehlt Linie", uint(l1), "Bhf", n1)
		}
		ker.Stop(pack, 3)
	}
}
예제 #2
0
파일: imp.go 프로젝트: CaptainSoOmA/Uni
// Eff.: s. ins1
func insert1(l Linie, n uint, l0 Linie, n0, u, t uint) {
	//
	// aktuell: vorherige aktuelle
	netz.Reposition()
	var bhf *bahnhof.Imp
	// aktuell: vorherige aktuelle, postaktuell: alt.
	if netz.ExPred(func(a Any) bool { b := a.(*bahnhof.Imp); return b.Linie() == l0 && b.Nummer() == n0 }) {
		// aktuell: (L0, n0), postaktuell: vorherige aktuelle
		bhf = netz.Get().(*bahnhof.Imp)
	} else {
		errh.Error2("fehlt: Linie", uint(l0), "Bhf", n0)
		ker.Stop(pack, 2)
	}
	netz.Reposition()
	// aktuell: vorherige aktuelle, postaktuell: (l0, n0)
	bhf1 := bhf.Clone().(*bahnhof.Imp)
	bhf1.Numerieren(l, n)
	bhf1.Umstieg()
	netz.Ins(bhf1)
	// aktuell: (l, n), postaktuell: vorherige aktuelle
	_gleis.Def(l, t)
	netz.Edge1(_gleis)
	// verbunden: vorherige aktuelle mit (l, n), aktuell: (l, n).
	edge(l0, n0, l, n, u)
	// postaktuell: (l0, n0), aktuell: (l, n)
}
예제 #3
0
파일: imp.go 프로젝트: CaptainSoOmA/Uni
func stop(a rob.Aktion) {
	//
	if !amEditieren {
		errh.Error2("Programmstop: Verletzung der Vor. in Methode", 0, "rob."+rob.Aktionstext[a]+"()", 0)
		ker.Terminate()
	}
}
예제 #4
0
파일: main.go 프로젝트: CaptainSoOmA/Uni
func main() {
	//
	scr.Switch(scr.TXT)
	var today, birthday *Imp
	today = New()
	today.Actualize()
	birthday = New()
	birthday.SetColours(col.LightWhite, col.Blue)
	scr.Colour(col.Yellow)
	scr.Write("Ihr Geburtsdatum:", 12, 0)
	birthday.Edit(12, 18)
	if birthday.Empty() {
		birthday.Actualize()
	} else {
		scr.Write(" war ein ", 12, 26)
		birthday.SetFormat(WD)
		birthday.Write(12, 35)
		errh.Error2("Sie sind heute", birthday.Distance(today), "Tage alt.", 0)
	}
	scr.Colours(col.ScreenF, col.ScreenB)
	scr.Cls()
	errh.Hint(" vor-/rückwärts: Pfeiltasten               fertig: Esc ")
	var (
		c kbd.Comm
		t uint
	)
	neu := true
loop:
	for {
		if neu {
			birthday.WriteYear(0, 0)
			neu = false
		}
		switch c, t = kbd.Command(); c {
		case kbd.Esc:
			break loop
		case kbd.Down:
			if t == 0 {
				birthday.Inc(Yearly)
			} else {
				birthday.Inc(Decadic)
			}
			neu = true
		case kbd.Up:
			if t == 0 {
				birthday.Dec(Yearly)
			} else {
				birthday.Dec(Decadic)
			}
			neu = true
		case kbd.PrintScr:
			birthday.PrintYear(0, 0)
			prt.GoPrint()
		}
	}
	ker.Terminate()
}
예제 #5
0
파일: imp.go 프로젝트: CaptainSoOmA/Uni
// Eff.: s. ins
func insert(l Linie, n uint, l0 Linie, n0, u uint) {
	//
	var bhf *bahnhof.Imp
	if netz.ExPred(func(a Any) bool { b := a.(*bahnhof.Imp); return b.Linie() == l0 && b.Nummer() == n0 }) {
		bhf = netz.Get().(*bahnhof.Imp)
	} else {
		errh.Error2("fehlt: Linie", uint(l0), "Bhf", n0)
		ker.Stop(pack, 1)
	}
	// aktuell: (l0, n0)
	bhf1 := bhf.Clone().(*bahnhof.Imp)
	bhf1.Numerieren(l, n)
	bhf1.Umstieg()
	netz.Ins(bhf1)
	edge(l0, n0, l, n, u)
	// postaktuell: (l0, n0), aktuell: (l, n)
}
예제 #6
0
func main() {
	const a = 100
	var p []string = []string{"Anaxagoras", "Aristoteles", "Cicero", "Jemand", "Demokrit", "Diogenes", "Epikur", "Heraklit", "Platon", "Protagoras", "Pythagoras", "Sokrates", "Thales", "Niemand"}
	var x, y uint
	for _, s := range p {
		img.Get(s, x, y)
		errh.Error(s, 0)
		if x+2*a < scr.NX() {
			x += a
		} else {
			x = 0
			y = a
		}
	}
	errh.Error2("", uint(len(p)), "Philosophen", 0)
	ker.Terminate()
}
예제 #7
0
파일: imp.go 프로젝트: CaptainSoOmA/Uni
func (x *Imp) Edit(l, c uint) {
	//
	x.Write(l, c)
	n := uint(0)
loop_n:
	for {
		i := uint(0)
	loop_i:
		for {
			weg := false
			switch i {
			case 0: // lang
				for {
					for {
						x.lang[n].Edit(l+lLa[x.f][n], c+cLa[x.f][n])
						if x.lang[n].Ord() >= 2 && // Englisch
							x.lang[n].Ord() <= 12 { // Griechisch
							break
						} else {
							errh.Error("keine Fremdsprache", 0)
						}
					}
					if x.lang[n].Empty() {
						if n > 1 {
							weg = true
							break
						} else {
							errh.Error2("", n+1, ". Fremdsprache fehlt", 0)
						}
					} else {
						break
					}
				}
			case 1: // from
				if weg {
					x.from[n].Clr()
					x.from[n].Write(l+lFr[x.f][n], c+cFr[x.f][n])
				} else {
					x.from[n].Edit(l+lFr[x.f][n], c+cFr[x.f][n])
				}
			case 2: // to
				if weg {
					x.to[n].Clr()
					x.to[n].Write(l+lTo[x.f][n], c+cTo[x.f][n])
				} else {
					for {
						x.to[n].Edit(l+lTo[x.f][n], c+cTo[x.f][n])
						if x.to[n].Empty() || x.to[n].Val() == 0 && x.to[n].Val() >= 12 {
							errh.Error("geht nich", x.to[n].Val())
						} else {
							break
						}
					}
				}
			}
			if i < 2 {
				i++
			} else {
				if x.from[n].Eq(x.to[n]) || x.from[n].Less(x.to[n]) {
					break loop_i
				} else {
					i = 1
				}
			}
		} // loop_i
		if n+1 < max {
			n++
		} else {
			k := uint(0)
			if x.multiple(&k) {
				errh.Error2("Die", k+1, ". Fremdsprache kommt mehrfach vor", 0)
			} else {
				break loop_n
			}
		}
	}
}
예제 #8
0
파일: imp.go 프로젝트: CaptainSoOmA/Uni
func (x *Imp) Del() Any {
	//
	if x.num == 0 {
		return x.empty.Clone()
	} else {
		x.num--
		x.pg[0].PutPos(1, x.num)
	}
	a := x.pg[x.dp].Get(x.idx[x.dp])
	if x.pg[x.dp].GetPos(0) == 0 { // we are on leaf level
		tst(1)
		x.pg[x.dp].Del(x.idx[x.dp])
		/**********************************************************
		  //  with pg [dp]
		      if idx [dp] + 1 < num {
		        for i:= idx [dp} + 1; i < num; i++ {
		          content [i - 1] = content [i]
		          pos [i] = pos [i + 1]
		        }
		      }
		      content [num - 1] = empty
		      pos [num] = 0
		  }
		  **********************************************************/
		for i := uint(0); i < x.pg[x.dp].GetNum(); i++ {
			errh.Error2("i =", i, ">>> Pos =", x.pg[x.dp].GetPos(i))
		}
		x.pg[x.dp].DecNum()
		if x.dp == 1 { // page underflow is allowed in the root
			x.write(x.pg[x.dp], 1)
			x.write(x.pg[0], 0)
			tst(4)
			return a
		} else { // x.dp > 1
			if x.pg[x.dp].GetNum() < N {
				x.removeUnderflow(x.dp)
			} else {
				x.write(x.pg[x.dp], x.pg[x.dp-1].GetPos(x.idx[x.dp-1]))
			}
		}
	} else { // pg [x.dp].pos [0]] > 0, i.e. we are not on leaf level
		// We look for the greatest object < x.Get (idx [x.dp]) in a node of depth x.dp,
		// copy it to x.content [idx [x.dp]] and replace it by x.empty:
		tst(10)
		d := x.dp
		for {
			n := x.idx[d]
			x.pg[d+1] = x.read(x.pg[d].GetPos(n))
			d++
			if x.pg[d].GetPos(x.idx[d]) == 0 { // we are on leaf level
				x.pg[d].DecNum()
				x.idx[d] = x.pg[d].GetNum()
				if x.idx[d] > 100 {
					ker.Stop(pack, 10)
				}
				x.pg[x.dp].Put(x.idx[x.dp], x.pg[d].Get(x.idx[d]))
				x.pg[d].Put(x.idx[d], x.empty)
				break
			}
		}
		x.write(x.pg[d], x.pg[d-1].GetPos(x.idx[d-1]))
		x.write(x.pg[x.dp], x.pg[x.dp-1].GetPos(x.idx[x.dp-1]))
		if x.pg[d].GetNum() < N {
			x.removeUnderflow(d)
		}
	}
	x.write(x.pg[0], 0)
	if x.num == 0 {
		// TODO
	} else if !x.ExGeq(a) {
		x.Jump(true)
	}
	return a
}
예제 #9
0
파일: imp.go 프로젝트: CaptainSoOmA/Uni
func (x *Imp) Step(forward bool) {
	//
	if x.num == 0 || x.dp == 0 {
		return
	}
	if forward {
		x.idx[x.dp]++
		if x.pg[x.dp].GetPos(x.idx[x.dp]) == 0 {
			if x.idx[x.dp] < x.pg[x.dp].GetNum() {
				return
			}
			// x.idx [x.dp] == x.pg [x.dp].GetNum()
			for {
				if x.dp == 1 {
					for x.pg[x.dp].GetPos(x.idx[0]) > 0 {
						x.dp++
					}
					x.idx[x.dp]--
					return
				}
				if x.dp == 0 {
					ker.Stop("übles Problem hoch", 3)
				}
				x.dp--
				if x.dp == 0 || x.idx[x.dp] < x.pg[x.dp].GetNum() {
					return
				}
			}
		} else { // x.pg [x.dp].pos [x.idx [x.dp]] > 0
			for {
				n := x.pg[x.dp].GetPos(x.idx[x.dp])
				x.dp++
				x.pg[x.dp] = x.read(n)
				x.idx[x.dp] = 0
				if x.pg[x.dp].GetPos(0) == 0 {
					return
				}
			}
		}
	} else { // backward
		rrx(1000*(1000*(1000+int(x.dp))+int(x.idx[x.dp])) + int(x.pg[x.dp].GetPos(x.idx[x.dp])))
		if x.pg[x.dp].GetPos(x.idx[x.dp]) == 0 {
			rrx(1)
			if x.idx[x.dp] == 0 {
				rrx(2)
				x.dp--
				rrx(3)
				if x.dp == 0 { // walk left downwards
					rrx(4)
					x.dp = 1
					x.idx[x.dp] = 0
					rrx(5)
				} else { // x.dp > 0
					for {
						if x.idx[x.dp] > 0 {
							x.idx[x.dp]--
							rrx(6)
							return
						} else {
							rrx(7)
							if x.dp == 0 {
								for x.pg[x.dp].GetPos(0) > 0 {
									x.dp++
								}
								rrx(8)
								return
							} else {
								x.dp--
								rrx(9)
							}
						}
					}
				}
			} else { // x.idx [x.dp] > 0
				rrx(10)
				x.idx[x.dp]--
				rrx(11)
				return
			}
		} else { // x.pg [x.dp].GetPos (x.idx [x.dp]) > 0
			errh.Error2("idx", x.idx[x.dp], ">>> Pos", x.pg[x.dp].GetPos(x.idx[x.dp]))
			for {
				rrx(12)
				n := x.pg[x.dp].GetPos(x.idx[x.dp])
				x.dp++ // hier ist der Wurm drin
				x.pg[x.dp] = x.read(n)
				if x.pg[x.dp].GetPos(x.pg[x.dp].GetNum()) == 0 {
					rrx(1300 + int(x.dp))
					if x.pg[x.dp].GetNum() > 0 {
						x.idx[x.dp] = x.pg[x.dp].GetNum() - 1
					} else {
						ker.Stop(pack, 11) // böses Problem
					}
					rrx(14)
					return
				} else {
					rrx(15)
					x.idx[x.dp] = x.pg[x.dp].GetNum()
				}
			}
		}
	}
}
예제 #10
0
파일: imp.go 프로젝트: CaptainSoOmA/Uni
func Report() {
	//
	errh.Error2("Bewegungen:", nB, "/ Drehungen:", nD)
}