guess_my_rule
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| guess_my_rule [2022/08/03 12:56] – [Guess My String Rule] frchris | guess_my_rule [2022/08/11 10:09] (current) – frchris | ||
|---|---|---|---|
| Line 11: | Line 11: | ||
| ==== Guess My Integer Rule==== | ==== Guess My Integer Rule==== | ||
| This is best used with the BlueJ IDE where you can make an instance of a class without writing a '' | 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 | * Make up your own rule | ||
| | | ||
| Line 19: | Line 19: | ||
| public class GuessMyIntegerRule | public class GuessMyIntegerRule | ||
| { | { | ||
| - | private String secretRule = "It must be prime"; | + | // Change secretRule to make your own rule |
| + | | ||
| + | | ||
| public boolean DoesThisIntFollowMyRule(int n) | public boolean DoesThisIntFollowMyRule(int n) | ||
| { | { | ||
| + | // change this code for checking if n follows your rule. | ||
| for(int i = 2; i < n; i++) | for(int i = 2; i < n; i++) | ||
| if (n % i == 0) | if (n % i == 0) | ||
| Line 40: | Line 43: | ||
| ==== Guess My String Rule ==== | ==== Guess My String Rule ==== | ||
| This is best using the Eclipse IDE | This is best using the Eclipse IDE | ||
| - | < | + | < |
| + | /** | ||
| + | * Make up your own rule | ||
| + | * | ||
| + | * @author Chris Thiel, OFMCap | ||
| + | * | ||
| + | */ | ||
| import java.util.Scanner; | import java.util.Scanner; | ||
| Line 49: | Line 58: | ||
| public GuessMyStringRule() | public GuessMyStringRule() | ||
| { | { | ||
| - | secretRule = "The String needed to contain a lower case s"; | + | // Change the following to make your own rule and hint: |
| + | |||
| + | | ||
| hint = "Ben follows the rule, but bend does not"; | hint = "Ben follows the rule, but bend does not"; | ||
| Line 90: | Line 101: | ||
| return secretRule; | return secretRule; | ||
| } | } | ||
| + | /** | ||
| + | /* change the following to determine if your rule is followed | ||
| + | */ | ||
| public boolean isCorrect(String guess) { | public boolean isCorrect(String guess) { | ||
| if (guess.indexOf(' | if (guess.indexOf(' | ||
| Line 100: | Line 114: | ||
| } | } | ||
| </ | </ | ||
| + | ====Rubric==== | ||
| + | - Name and seat in a comment? | ||
| + | - Unique secret rule | ||
| + | - Hint provided | ||
| + | - Attempt to test if input follows the rule | ||
| + | - Functions according to spec | ||
| + | - Follows best practices (names of variables, indenting, etc) | ||
guess_my_rule.1659545788.txt.gz · Last modified: 2022/08/03 12:56 by frchris