Twenty questions

On Github

  1. Navigate to your Github repo on github.com

  2. Click the green Code button

  3. Click the Codespaces tab

  4. Click the + to create a new codespace.

In the codespace

  1. Wait for the codespace to open up. (This will take a few minutes)

  2. In the file navigator on the left, right click on start-project and choose “Open in Integrated Terminal”

  3. In the terminal, type ./start-project twenty-questions

Open TwentyQuestions.java

  1. In the file navigator open projects/twenty-questions

  2. Click on TwentyQuestions.java

  3. At the top right of the page there should be a trianglar “play” button. Click it.

Think of an animal

  1. Think of an animal and then answer the questions from the program.

  2. It should print “Is it a mammal?”

  3. Type “y” or “n” and hit return.

  4. Keep playing.

Now make it better!

As it stands, this program plays a boring game of One Question. You should extend it, by creating nested if/else pairs to at least Three Questions.

The code will be pretty repetitive at this point. That’s okay. Feel free to make it better if you see a way but we’ll talk about that as a class later.