Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<groupId>io.zipcoder</groupId>
<artifactId>MicroLabs-OOP-TooLargeTooSmall</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>


</project>
36 changes: 36 additions & 0 deletions src/main/java/GuessingGame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import java.util.Scanner;
import java.lang.Math;
public class GuessingGame{
public static void main(String[] args) {

System.out.println("Guess a number!");

int answer = (int) (Math.random() * 100) + 1;

int lives = 10;

Scanner input = new Scanner(System.in);
System.out.println("Let's play a game...\nI'm thinking of a number between 1 and 100\n" +
"You have 10 tries before you lives run out!");
System.out.print("What is your guess?");
while (lives > 0) {
int guess = input.nextInt();
if (guess == answer) {
System.out.println("You win this time...");
break;
}
else if (guess > answer) {
System.out.println("Seems a bit high! \n Try again you have " + (lives - 1) + " tries remaining!");
}
else {
System.out.println("Kind of a low ball! \n Try again you have " + (lives - 1) + " tries remaining!");
}
lives--;
if (lives==0) {
System.out.println("It seems you're out of lives... BOOM!");
}


}
}
}
34 changes: 33 additions & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
import java.util.Scanner;

/**
* Created by iyasuwatts on 10/17/17.
*/
public class Main {

public static void main(String[] args){


System.out.println("Guess a number!");

int answer = (int) (Math.random() * 100) + 1;

int lives = 10;

Scanner input = new Scanner(System.in);
System.out.println("Let's play a game...\nI'm thinking of a number between 1 and 100\n" +
"You have 10 tries before you lives run out!");
System.out.print("What is your guess?");
while (lives > 0) {
int guess = input.nextInt();
if (guess == answer) {
System.out.println("You win this time...");
break;
}
else if (guess > answer) {
System.out.println("Seems a bit high! \n Try again you have " + (lives - 1) + " tries remaining!");
}
else {
System.out.println("Kind of a low ball! \n Try again you have " + (lives - 1) + " tries remaining!");
}
lives--;
if (lives==0) {
System.out.println("It seems you're out of lives... BOOM!");
}


}

}
}