generated from fastai/fastpages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Classes FRQ" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "java" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"2\n", | ||
"5\n", | ||
"8\n", | ||
"11\n", | ||
"8\n", | ||
"5\n", | ||
"2\n", | ||
"2\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"public class AdditionPattern {\n", | ||
" private int current;\n", | ||
" private int increment;\n", | ||
" \n", | ||
" public AdditionPattern(int start, int inc) {\n", | ||
" current = start;\n", | ||
" increment = inc;\n", | ||
" }\n", | ||
" // Variable sets integer currentNumber and returns the current value\n", | ||
" public int currentNumber() {\n", | ||
" return current;\n", | ||
" }\n", | ||
" // Increments the values\n", | ||
" public void next() {\n", | ||
" current += increment;\n", | ||
" }\n", | ||
" // Subtracts Values\n", | ||
" public void prev() {\n", | ||
" if (current > increment) {\n", | ||
" current -= increment;\n", | ||
" }\n", | ||
" }\n", | ||
"\n", | ||
" public static void main(String[] args) {\n", | ||
" AdditionPattern plus3 = new AdditionPattern(2, 3);\n", | ||
" System.out.println(plus3.currentNumber()); // expected output: 2\n", | ||
" plus3.next();\n", | ||
" System.out.println(plus3.currentNumber()); // expected output: 5\n", | ||
" plus3.next();\n", | ||
" System.out.println(plus3.currentNumber()); // expected output: 8\n", | ||
" plus3.next();\n", | ||
" System.out.println(plus3.currentNumber()); // expected output: 11\n", | ||
" plus3.prev();\n", | ||
" System.out.println(plus3.currentNumber()); // expected output: 8\n", | ||
" plus3.prev();\n", | ||
" System.out.println(plus3.currentNumber()); // expected output: 5\n", | ||
" plus3.prev();\n", | ||
" System.out.println(plus3.currentNumber()); // expected output: 2\n", | ||
" plus3.prev();\n", | ||
" System.out.println(plus3.currentNumber()); // expected output: 2\n", | ||
" }\n", | ||
"}\n", | ||
"AdditionPattern.main(null);\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Java", | ||
"language": "java", | ||
"name": "java" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": "java", | ||
"file_extension": ".jshell", | ||
"mimetype": "text/x-java-source", | ||
"name": "Java", | ||
"pygments_lexer": "java", | ||
"version": "18.0.2+0" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |