Created
July 3, 2020 12:03
-
-
Save JHarry444/bb40eba05be464f2d5ae0081609a986e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum CoinFlip { | |
HEADS, TAILS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment