-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fed0a13
commit 0b89a70
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Twenty Questions | ||
Ask the user for: | ||
- 20 (y/n) questions. | ||
|
||
*note: this was dumbed down due to the rubic* | ||
## Rubic | ||
![Rubic](./rubic.png) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.saahild</groupId> | ||
<artifactId>twentyquestions</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
</project> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package com.saahild; | ||
|
||
import java.util.Scanner; | ||
|
||
public class Main { | ||
private static void CheckIfNoCountIsAboveRequestedLimit(int n) { | ||
if(n >= 5) { | ||
System.out.println("I have lost because n is over 5"); | ||
System.out.println("Goodbye"); | ||
System.exit(0); | ||
} | ||
} | ||
// i was forced to dumb this down. | ||
public static void main(String[] args) { | ||
try (Scanner user = new Scanner(System.in)) { | ||
int noCount = 0; | ||
System.out.println("Think of something thats in a classroom..."); | ||
System.out.println("Is your thing red?: "); | ||
String pr1 = user.next(); | ||
if("y".equals(pr1)) { | ||
System.out.println("Is your thing rubbery."); | ||
String pr2_y = user.next(); | ||
if("y".equals(pr2_y)) { | ||
System.out.println("Is your thing used on a pencil?"); | ||
String pr3_y = user.next(); | ||
if( "y".equals(pr3_y)) { | ||
System.out.println("I win"); | ||
} else { | ||
noCount++; | ||
CheckIfNoCountIsAboveRequestedLimit(noCount); | ||
System.out.println("Im Out"); | ||
} | ||
} else { | ||
noCount++; | ||
CheckIfNoCountIsAboveRequestedLimit(noCount); | ||
System.out.println("Is your thing an eraser?"); | ||
String pr3_n = user.next(); | ||
if( "y".equals(pr3_n)) { | ||
System.out.println("I win"); | ||
} else { | ||
System.out.println("Dang i lost"); | ||
} | ||
} | ||
} else if("n".equals(pr1)) { | ||
noCount++; | ||
CheckIfNoCountIsAboveRequestedLimit(noCount); | ||
System.out.println("Is your thing blue."); | ||
String pr2_n = user.next(); | ||
if("y".equals(pr2_n)) { | ||
System.out.println("Is your thing used on a laptop case?"); | ||
String pr3_y = user.next(); | ||
if( "y".equals(pr3_y)) { | ||
System.out.println("I win"); | ||
} else { | ||
noCount++; | ||
CheckIfNoCountIsAboveRequestedLimit(noCount); | ||
System.out.println("Im Out"); | ||
} | ||
} else { | ||
noCount++; | ||
CheckIfNoCountIsAboveRequestedLimit(noCount); | ||
System.out.println("Is your thing multi-color?"); | ||
String pr3_n = user.next(); | ||
if( "y".equals(pr3_n)) { | ||
System.out.println("Is your thing a water bottle"); | ||
String pr4_n = user.next(); | ||
if( "y".equals(pr4_n)) { | ||
System.out.println("I win"); | ||
} else { | ||
System.out.println("Dang i lost"); | ||
} | ||
} else { | ||
noCount++; | ||
CheckIfNoCountIsAboveRequestedLimit(noCount); | ||
System.out.println("Is your thing solid. "); | ||
String pr4_n = user.next(); | ||
if("y".equals(pr4_n)) { | ||
System.out.println("Is your thing water. "); | ||
String pr5_n = user.next(); | ||
if("y".equals(pr5_n)) { | ||
System.out.println("I win"); | ||
} else { | ||
noCount++; | ||
CheckIfNoCountIsAboveRequestedLimit(noCount); | ||
System.out.println("I lose"); | ||
} | ||
} else { | ||
noCount++; | ||
CheckIfNoCountIsAboveRequestedLimit(noCount); | ||
System.out.println("Is your thing a table. "); | ||
String pr6_n = user.next(); | ||
if("y".equals(pr6_n)) { | ||
System.out.println("I win"); | ||
} else { | ||
noCount++; | ||
CheckIfNoCountIsAboveRequestedLimit(noCount); | ||
System.out.println("I lose"); | ||
} | ||
} | ||
} | ||
} | ||
} else { | ||
System.err.println("Maybe use (y/n)"); | ||
} | ||
} | ||
} | ||
} |