public int AddThrow(string instructionString) { int arrowInt; while (true) { Console.Write(instructionString + " "); string userInput = Console.ReadLine(); if (userInput.Length == 0) { Random randomThrow = new Random(); arrowInt = randomThrow.Next(highestPoint); Console.SetCursorPosition(0, Console.CursorTop - 1); Console.WriteLine($"{instructionString} {arrowInt} (random throw) {new string(' ', instructionString.Length)}"); break; } else { try { arrowInt = Convert.ToInt32(userInput); if (arrowInt < 0 || arrowInt > highestPoint) { Console.WriteLine("Please write an integer between 0 and " + highestPoint); } else if (arrowInt == 0) { Console.WriteLine("Didn't throw"); break; // Successful input } else { DartBoard playerDartBoard = new DartBoard(arrowInt); arrowInt = playerDartBoard.ArrowStrike; break; // Also successful input } } catch (FormatException) { Console.WriteLine("Please write an integer"); } catch (Exception e) { Console.WriteLine(e.Message); } } } return(arrowInt); }
private void PicBox_Paint(object sender, PaintEventArgs e) { DartBoard.DrawBoard(e, this.pictureBox1); }
public Throw(int X, int Y) { this.Point = DartBoard.Throw(X, Y); }