ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
171
171
EMPFEHLEN
-
20.07.09 16:59 #1
- Registriert seit
- Oct 2007
- Beiträge
- 325
Hier erstmal alles bis zu Teilaufgabe B ohne Erweiterungen:
Code vbnet:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
Public Class Form1 Private Sub Button_Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Start.Click If Not (Integer.TryParse(Text_Breite.Text, Nothing) _ AndAlso Integer.TryParse(Text_Höhe.Text, Nothing) _ AndAlso Integer.TryParse(Text_X.Text, Nothing) _ AndAlso Integer.TryParse(Text_Y.Text, Nothing) _ AndAlso Integer.TryParse(Text_Drehwinkel.Text, Nothing) _ AndAlso Single.TryParse(Text_Schrittweite.Text, Nothing) _ AndAlso Integer.TryParse(Text_Iterationszahl.Text, Nothing)) OrElse Text_Startliste.Text = "" OrElse Text_Ersetzungsliste.Text = "" Then MessageBox.Show("Bitte fülle alle Felder korrekt aus!", "Fehlermeldung", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Return End If Dim Iterationszahl As Integer = CInt(Text_Iterationszahl.Text) Dim Ersetzungsliste As String = Text_Ersetzungsliste.Text Dim Aktionenliste As String = ReplaceErsetzungsliste(Text_Startliste.Text, Ersetzungsliste, Iterationszahl) Dim Breite As Integer = CInt(Text_Breite.Text) Dim Höhe As Integer = CInt(Text_Höhe.Text) Dim X As Integer = CInt(Text_X.Text) Dim Y As Integer = CInt(Text_Y.Text) Dim Schrittweite As Single = CSng(Text_Schrittweite.Text) Dim Drehwinkel As Integer = CInt(Text_Drehwinkel.Text) Dim Aktionen As Char() = Aktionenliste.ToCharArray Dim currentAngle As Integer = 0 Dim currentX As Single = X Dim currentY As Single = Höhe - Y Dim Gedächtnis As New Stack(Of State) Dim Pic As New Bitmap(Breite, Höhe) Using g As Graphics = Graphics.FromImage(Pic) For Each Aktion As Char In Aktionen Select Case Aktion Case "F"c g.DrawLine(Pens.Black, currentX, currentY, CSng(currentX + Math.Cos(ToRadians(currentAngle)) * Schrittweite), CSng(currentY + Math.Sin(ToRadians(currentAngle)) * Schrittweite)) currentX = CSng(currentX + Math.Cos(ToRadians(currentAngle)) * Schrittweite) currentY = CSng(currentY + Math.Sin(ToRadians(currentAngle)) * Schrittweite) Case "+"c currentAngle -= Drehwinkel Case "-"c currentAngle += Drehwinkel Case "["c Gedächtnis.Push(New State(currentAngle, New PointF(currentX, currentY))) Case "]"c Dim s As State = Gedächtnis.Pop currentAngle = s.Angle currentX = s.Position.X currentY = s.Position.Y End Select Next PictureBox1.Image = Pic End Using End Sub Private Function ToRadians(ByVal a As Integer) As Single Return CSng(a / 180 * Math.PI) End Function Private Function ReplaceErsetzungsliste(ByVal Liste As String, ByVal ReplaceWith As String, ByVal n As Integer) As String Dim ListeNeu As String ListeNeu = Liste.Replace("F", ReplaceWith) If n > 0 Then Return ReplaceErsetzungsliste(ListeNeu, ReplaceWith, n - 1) Else Return ListeNeu End Function End Class Public Structure State Public Property Angle As Integer Public Property Position As PointF Sub New(ByVal Angle As Integer, ByVal Pos As PointF) Me.Angle = Angle Me.Position = Pos End Sub End Structure
Im Anhang nochmal das ganze Projekt.
Ist übrigens in Visual Basic 10 geschrieben.
Leider habe ich wahrscheinlich keine Zeit mehr, das Projekt zu erweitern. Hat trotzdem Spaß gemacht.
Geändert von Masterclavat (27.07.09 um 17:19 Uhr)
Ähnliche Themen
-
[QUIZ#9] x y z (VB.Net)
Von Erik im Forum ArchivAntworten: 0Letzter Beitrag: 20.07.09, 17:16 -
[QUIZ#1] Masterclavat (VB.NET)
Von Masterclavat im Forum ArchivAntworten: 0Letzter Beitrag: 18.09.08, 22:13 -
Quiz?
Von MeisterLampion im Forum Office-AnwendungenAntworten: 12Letzter Beitrag: 03.11.06, 15:48 -
Quiz
Von alkaline im Forum PHPAntworten: 0Letzter Beitrag: 27.09.04, 10:16 -
php Quiz
Von Sim im Forum PHPAntworten: 0Letzter Beitrag: 09.05.04, 12:43





Login





