Package project2
Class Dart
java.lang.Object
project2.Dart
Simulate a dart that can be thrown at a standard dartboard with 20 wedges and 3 types of rings
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getRing()
Return which of the 3 rings the dart landed inint
getScore()
Return the score of the thrown dartint
getWedge()
Return which of the 20 wedges the dart landed invoid
Throw a darttoString()
Return a reference to a String representation of the dart's data
-
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 hitr
- 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
Return a reference to a String representation of the dart's data -
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
-