public void SetAcceleration(int acc) { try { if (acc <= MaxAcceleration && acc >= 0) { _acceleration = acc; } else { throw new Exception("Неверный разгон"); } } catch (Exception e) { NotValidInput?.Invoke(); } }
public void SetBraking(int br) { try { if (br <= MaxBraking && br >= 0) { _braking = br; } else { throw new Exception("Неверное торможение"); } } catch (Exception e) { NotValidInput?.Invoke(); } }
public void Move(int time) { try { if (time >= 0) { Coordinates = Coordinates + Speed * time; } else { throw new Exception("Отрицательное время"); } } catch (Exception e) { NotValidInput?.Invoke(); } }
public void Braking(int time) { try { if (time >= 0) { Coordinates = (int)(Coordinates + Speed * time - (_braking * Math.Pow(time, 2) / 2)); Speed = Speed - _braking * time; if (Speed < 0) { Speed = 0; } } else { throw new Exception("Отрицательное время."); } } catch (Exception e) { NotValidInput?.Invoke(); } }
public void Overclocking(int time) { try { if (time >= 0) { Coordinates = (int)(Coordinates + Speed * time + (_acceleration * Math.Pow(time, 2) / 2)); Speed = _acceleration * time + Speed; if (Speed > MaxSpeed) { Speed = MaxSpeed; } } else { throw new Exception("Отрицательное время"); } } catch (Exception e) { NotValidInput?.Invoke(); } }