Package project2

Class Dart

java.lang.Object
project2.Dart

public class Dart extends Object

Simulate a dart that can be thrown at a standard dartboard with 20 wedges and 3 types of rings

  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor
    Dart(int w, int r)
    Parameterized constructor - to be used only for testing
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Return which of the 3 rings the dart landed in
    int
    Return the score of the thrown dart
    int
    Return which of the 20 wedges the dart landed in
    void
    Throw a dart
    Return a reference to a String representation of the dart's data

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Dart

      public Dart()
      Default constructor
    • Dart

      public Dart(int w, int r)
      Parameterized constructor - to be used only for testing
      Parameters:
      w - An integer 1..20 indicating which wedge we will pretend was hit
      r - An integer 1..3 indicating which ring we will pretend was hit
  • Method Details

    • getWedge

      public int getWedge()
      Return which of the 20 wedges the dart landed in
      Returns:
      An integer 1..20 indicating which wedge was hit
    • getRing

      public int getRing()
      Return which of the 3 rings the dart landed in
      Returns:
      An integer 1..3 indicating which ring was hit
    • getScore

      public int getScore()
      Return the score of the thrown dart
      Returns:
      An integer 1..60 indicating the score of the dart
    • toString

      public String toString()
      Return a reference to a String representation of the dart's data
      Overrides:
      toString in class Object
    • throwDart

      public void throwDart()

      Throw a dart

      Note: We assume here that all three rings are equally likely to be hit, which a dart player will tell you is absurd