Skip to content

Instantly share code, notes, and snippets.

@JHarry444
Created July 3, 2020 12:03
Show Gist options
  • Save JHarry444/bb40eba05be464f2d5ae0081609a986e to your computer and use it in GitHub Desktop.
Save JHarry444/bb40eba05be464f2d5ae0081609a986e to your computer and use it in GitHub Desktop.
public class App {
public static final Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
System.out.println(flip(CoinFlip.HEADS));
boolean b = true;
while (b) {
try {
System.out.println("Enter a number:");
int i = Integer.parseInt(scan.nextLine());
System.out.println(i);
} catch (Exception e) {
}
}
scan.close();
}
public static boolean flip(CoinFlip call) {
CoinFlip result = null;
if (Math.random() > 0.5) {
result = CoinFlip.TAILS;
} else {
result = CoinFlip.HEADS;
}
return result == call;
}
}
public enum CoinFlip {
HEADS, TAILS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment