Aufgabe 5: zwei Ampeln
Das Auto soll nun vor beiden Ampeln stoppen. Sie sind synchron geschaltet.
Lösung als Struktogramm
|
Erläuterungen:
Im Quellcode müssen die Ortsabfragen nun mit ODER auch die zweite Ampel
einbeziehen
if (Auto1.xPosVorne > Ampel1.xPos - 1) and (Auto1.xPosVorne <= Ampel1.xPos) then |
if ((Auto1.xPosVorne > Ampel1.xPos - 1) and (Auto1.xPosVorne <= Ampel1.xPos)) or ((Auto1.xPosVorne > Ampel2.xPos - 1) and (Auto1.xPosVorne <= Ampel2.xPos)) then |
und analog
if (Auto1.xPosVorne > Ampel1.xPos - 100) and (Auto1.xPosVorne <= Ampel1.xPos - 1) then |
if ((Auto1.xPosVorne > Ampel1.xPos - 100) and (Auto1.xPosVorne <= Ampel1.xPos - 1)) or ((Auto1.xPosVorne > Ampel2.xPos - 100) and (Auto1.xPosVorne <= Ampel2.xPos - 1)) then |
![]() |
|
![]() |
|
![]() |
Zur
nächsten Seite
![]() |
© 2004 GK 11 If und G. Kubitz Hannah-Arendt-Gymnasium, Lengerich Letztes Update: 17.11.04 |