public class private double private double ang private Graphics Gr pri

 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
public class T
{
private double x, y;
private double ang;
private Graphics Gr;
private Pen Pn;
public T(double a, double b, double c, Graphics g, Pen p)
{
x = a;
y = b;
ang = c;
Gr = g;
Pn = p;
}
public double Rad(double d)
{
return (Math.PI / 180) * d;
}
public void turnLeft(double d)
{
ang += d;
}
public void turnRight(double d)
{
ang -= d;
}
public void Forward(double d)
{
double x0 = x;
double y0 = y;
x += d * Math.Cos(Rad(ang));
y += d * Math.Sin(Rad(ang));
Gr.DrawLine(Pn, new PointF((float)x0, (float)y0), new PointF((float)x, (float)y));
}
}