Skip to content

Commit

Permalink
feat(project): twentyquestions
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonGamerBot-QK committed Aug 30, 2024
1 parent fed0a13 commit 0b89a70
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
7 changes: 7 additions & 0 deletions twentyquestions/README.md
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)
16 changes: 16 additions & 0 deletions twentyquestions/pom.xml
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>
Binary file added twentyquestions/rubic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions twentyquestions/src/main/java/com/saahild/Main.java
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)");
}
}
}
}

0 comments on commit 0b89a70

Please sign in to comment.