Created
December 18, 2020 20:36
-
-
Save Ptolemy2002/962ba3f54cecaff212c5368ee789567c 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
class Main { | |
public static void test(int roadRunner, int coyote, int edge) { | |
System.out.println("Roadrunner Position: " + roadRunner + "; Coyote Position: " + coyote + "; edge: " + edge + ";"); | |
System.out.println(); | |
if (!(roadRunner < edge)) { | |
System.out.println("Roadrunner did not run."); | |
} | |
//while (!edge) | |
while (roadRunner < edge) { | |
//run(); | |
roadRunner++; | |
System.out.println("Roadrunner ran. Position: " + roadRunner); | |
if (roadRunner > edge) { | |
System.out.println("Off the edge!"); | |
} else { | |
System.out.println("Not off the edge."); | |
} | |
} | |
System.out.println(); | |
//do while (!edge) | |
do { | |
//run(); | |
coyote++; | |
System.out.println("Coyote ran. Position: " + coyote); | |
if (coyote > edge) { | |
System.out.println("Off the edge!"); | |
} else { | |
System.out.println("Not off the edge."); | |
} | |
} while (coyote < edge); | |
} | |
public static void main(String[] args) { | |
System.out.println("Neither Coyote nor roadrunner are on the edge:"); | |
test(0, 0, 1); | |
System.out.println("---------------------------"); | |
System.out.println("Coyote and roadrunner are both on the edge:"); | |
test(1, 1, 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment