Skip to content

Commit

Permalink
First two frqs
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby-Leeder committed Feb 25, 2024
1 parent af4f8c7 commit 011ee6a
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _notebooks/2024-02-15-Tri-2-Final-FRQ-1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"3. When initializing an Array I have to put int the length of it\n",
"4. In order to find the length of array I use .length as a property not a method.\n",
"5. No .append(), have to just set the value which works because the length of the array is already set. \n",
"6. \n"
"\n"
]
},
{
Expand Down
104 changes: 104 additions & 0 deletions _notebooks/2024-02-15-Tri-2-Final-FRQ-2.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"title: FRQ 2\n",
"description: Second FRQ for collegeboard FRQ final\n",
"toc: true\n",
"layout: post\n",
"courses: { ToC: {week: 23} }\n",
"---"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"vscode": {
"languageId": "java"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"+A+++\n",
"H*++*\n"
]
}
],
"source": [
"public class Main{\n",
" public static void main (String args[]){\n",
" HiddenWord puzzle = new HiddenWord(\"HARPS\");\n",
" System.out.println(puzzle.getHint(\"AAAAA\"));\n",
" System.out.println(puzzle.getHint(\"HEART\"));\n",
" }\n",
"}\n",
"\n",
"public class HiddenWord{\n",
" private String word;\n",
" public HiddenWord(String word){\n",
" this.word = word;\n",
" }\n",
" public String getHint(String guess){\n",
" String hint = \"\";\n",
" for (int i = 0; i < guess.length(); i++){\n",
" if (this.word.contains(String.valueOf(guess.charAt(i)))){\n",
" if (this.word.charAt(i) == guess.charAt(i)){\n",
" hint = hint + guess.charAt(i);\n",
" }\n",
" else {\n",
" hint = hint + \"+\";\n",
" }\n",
" }\n",
" else {\n",
" hint = hint + \"*\";\n",
" }\n",
" }\n",
" return hint;\n",
" }\n",
"}\n",
"Main.main(null);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Learnings:\n",
"\n",
"1. I can check if a letter is contained in a string by using the .contains() method on the string\n",
"2. length of a string is a method, length(). Length of an array is a property of the class. \n",
"3. I can't iterate through a string using brackents, I need to do charAt(). \n",
"4. String.contains can only include a string as the parameter, not a char. You need to convert a char if you're going to use a char. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"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": "20.0.2+9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 011ee6a

Please sign in to comment.