guess_my_rule
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
guess_my_rule [2020/05/30 15:01] – created frchris | guess_my_rule [2022/08/03 12:02] – [Guess My Integer Rule] frchris | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | **Guess My Rule** | + | ===== Guess My Rule ===== |
Guess My Rule games are games in which one person thinks up a secret rule, and then gives clues by stating some examples of some that follow the " | Guess My Rule games are games in which one person thinks up a secret rule, and then gives clues by stating some examples of some that follow the " | ||
For example, The secret rule might be that it is an integer that is a prime number. The rule-maker Starts with "2 follows my rule, but 4 does not" | For example, The secret rule might be that it is an integer that is a prime number. The rule-maker Starts with "2 follows my rule, but 4 does not" | ||
+ | In our computer version, the user asks about a certain '' | ||
- | ====== Guess My Integer ====== | + | To be fair, the secret rule cannot involve any random behavior. |
+ | |||
+ | |||
+ | ==== Guess My Integer | ||
+ | This is best used with the BlueJ IDE where you can make an instance of a class without writing a '' | ||
+ | < | ||
+ | * Make up your own rule | ||
+ | * | ||
+ | * @author Chris Thiel, OFMCap | ||
+ | * | ||
+ | */ | ||
+ | public class GuessMyIntegerRule | ||
+ | { | ||
+ | private String secretRule = "It must be prime"; | ||
+ | public boolean DoesThisIntFollowMyRule(int n) | ||
+ | { | ||
+ | for(int i = 2; i < n; i++) | ||
+ | if (n % i == 0) | ||
+ | return false; | ||
+ | return true; | ||
+ | } | ||
+ | |||
+ | public String IGiveUp() | ||
+ | { | ||
+ | return secretRule; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | ==== Guess My String Rule ==== | ||
guess_my_rule.txt · Last modified: 2022/08/11 10:09 by frchris