You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Übungen_LF6_WinFormanwendung
|
|
|
|
|
{
|
|
|
|
|
class Auto : Button
|
|
|
|
|
{
|
|
|
|
|
private int speed;
|
|
|
|
|
public bool zielErreicht = false;
|
|
|
|
|
|
|
|
|
|
public int AutoSpeed
|
|
|
|
|
{
|
|
|
|
|
get { return this.speed; }
|
|
|
|
|
set { this.speed = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Auto()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Auto(int newSpeed, int x_Pos, int y_Pos, string Name)
|
|
|
|
|
{
|
|
|
|
|
speed = newSpeed;
|
|
|
|
|
this.Left = x_Pos;
|
|
|
|
|
this.Top = y_Pos;
|
|
|
|
|
this.Text = Name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//fahren == True wenn fahren kann und nicht
|
|
|
|
|
public bool fahren(int zielXpos)
|
|
|
|
|
{
|
|
|
|
|
if(this.Left <= zielXpos && speed > 0)
|
|
|
|
|
{
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
Thread.Sleep(100 - speed);
|
|
|
|
|
|
|
|
|
|
Left += 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
zielErreicht = true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|