Commit e6ef810c authored by @thx's avatar @thx Committed by @thx
Browse files

Add skeleton for Winter 2022

# IntelliJ project files
# macOS folder attributes
# Compiled class file
# Log file
# BlueJ files
# Mobile Tools for Java (J2ME)
# Package Files #
# virtual machine crash logs, see
\ No newline at end of file
# EX01: Guessing Game
Welcome to CSE 332! This is your first programming assignment of the course. We will also help you get your computer set up for future assignments.
"Guessing Game" is a game with two parties: the "chooser" and the "guesser":
- The "chooser" picks a natural number larger than zero, and when given a guess, will return whether if the real answer is higher or lower.
- The "guesser" must guess what the number is by repeatedly making guesses to the "chooser" until the
correct answer is found.
## Tasks
### Set Up
Before you begin, go through the [Setting Up Your CSE 332 Environment](
handout. This will prepare your development environment for both this assignment and future programming projects.
After you have IntelliJ and Git set up, follow the instructions on that document to clone the repository that we individually generate for
everyone. You should be cloning `ex01-yourNetID`, instead of `ex01-public`.
### Completing the Exercise
Write Java code for `findNumber()`, a method that simulates the "guesser" in a guessing game by making a series of guesses
and returning the correct answer.
You should not have to bruteforce the number one-by-one. If the number chosen is $`n \geq 2`$, your code may make at
most $`2 \log_2(n)`$ guesses. What kind of algorithm (that you've learned from CSE 143) should you be using here to achieve
this complexity class?
Also note that there is no upper bound on the number the "chooser" can pick, so this is not something that you should
Open `src/main/java/` to get started. It might also be helpful to take a look at the ``
interface; however, you should only edit the method `findNumber` in ``. When you are not sure about what behavior
to implement, be sure to check the method's comments _and_ any potential parent classes that it extends/implements -- this
technique will become extremely important in the projects.
This repository will not contain the testing code for the staff `Chooser` which will be used to autograde your exercise.
However, if you just want to test if you have set up IntelliJ and Java correctly, you can click the green Run arrow
in `src/test/java/` to run a sample test to test compilation.
### Submission on Gradescope
Log into Gradescope [here]( using your UW email. If you do not see CSE 332, let the course staff know using a private Ed post or by writing to `cse332-staff@cs`.
If this is your first time submitting a coding assignment on Gradescope, take a look at
the [Submitting Projects]( handout.
Remember to use the GitLab option on Gradescope instead of uploading files directly.
### Grading
Submit on Gradescope to get your grade. There are no hidden tests for EX01, so the percentage that you see on Gradescope is your final grade.
### Important Notes
1. Avoid using `System.out.println()` when running the autograder. If you use any print statements, always remove them -- they perform poorly with large datasets.
2. There is a small buffer on top of the $`2\log_2(k)`$ to handle scenarios such as when $`n = 2`$.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""
\ No newline at end of file
import java.math.BigInteger;
* A Chooser will pre-emptively choose a number that a Guesser must guess.
public interface Chooser {
* You can use this method to guess any number and the chooser will return
* a String on whether the number numToGuess is "correct", "higher", or "lower"
* @param numToGuess An arbitrary number to guess.
* @return "correct" (your answer is correct),
* "higher" (the correct answer is higher),
* or "lower" (the correct answer is lower)
String guess(BigInteger numToGuess);
import java.math.BigInteger;
public class Guesser {
* This method must return the number Chooser c has chosen. c can guess() any
* number and tell you whether the number is "correct", "higher", or "lower".
* @param c The "chooser" that has chosen a number you must guess.
* @return The number that the "chooser" has chosen
public static BigInteger findNumber(Chooser c) {
// Tip: If you're not sure how to work with BigInteger numbers, we encourage
// you to look up its Javadoc online.
throw new RuntimeException("Remove this line and implement me!");
import org.junit.Test;
import java.math.BigInteger;
public class TestDummy {
public void guesserRuns() {
// Only tests that we are able to compile and run.
// Click the green Play button, and choose "Run 'guesserRuns()'".
// You should see a RuntimeException being thrown.
Guesser.findNumber(new DummyChooser());
public static class DummyChooser implements Chooser {
public String guess(BigInteger i) {
return "correct";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment