Skip to content

Commit 90474b1

Browse files
committed
Merge branch 'master' of https://github.com/bhoffman0/CSAwesome
2 parents 8ce1fea + e61349f commit 90474b1

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

_sources/Unit1-Getting-Started/calling-class-methods-2026.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,19 @@ When calling the ``square`` method, the return value can be stored in a variable
149149

150150
.. |visualization2| raw:: html
151151

152-
<a href="https://pythontutor.com/render.html#code=%20%20%20%20%20%20public%20class%20MethodTrace%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20public%20static%20int%20square%28int%20x%29%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%28x%20*%20x%29%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%20%20public%20static%20int%20divide%28int%20x,%20int%20y%29%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%28x%20/%20y%29%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%20%20public%20static%20void%20main%28String%5B%5D%20args%29%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20System.out.println%28square%283%29%20%2B%20divide%286,2%29%29%3B%20%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D&cumulative=false&curInstr=0&heapPrimitives=nevernest&mode=display&origin=opt-frontend.js&py=java&rawInputLstJSON=%5B%5D&textReferences=false" target="_blank">visualization</a>
152+
<a href="https://pythontutor.com/render.html#code=%20%20%20%20%20%20public%20class%20MethodTrace%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20public%20static%20int%20square%28int%20x%29%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%28x%20*%20x%29%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%20%20public%20static%20int%20divide%28int%20x,%20int%20y%29%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%28x%20/%20y%29%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%20%20public%20static%20void%20main%28String%5B%5D%20args%29%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20System.out.println%28square%283%29%20%2B%20divide%285,2%29%29%3B%20%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D&cumulative=false&curInstr=0&heapPrimitives=nevernest&mode=display&origin=opt-frontend.js&py=java&rawInputLstJSON=%5B%5D&textReferences=false" target="_blank">visualization</a>
153153

154154
.. mchoice:: traceMethods1
155155
:random:
156156
:practice: T
157-
:answer_a: 12
158-
:answer_b: 9+3
159-
:answer_c: 93
160-
:answer_d: square(3)+divide(6,2)
157+
:answer_a: 11
158+
:answer_b: 11.5
159+
:answer_c: 92
160+
:answer_d: square(3)+divide(5,2)
161161
:answer_e: Nothing, it does not compile.
162162
:correct: a
163163
:feedback_a: Yes, the square(3) method is called first and returns 9. Then the divide(6,2) method is called and returns 3. The sum of 9 and 3 is 12.
164-
:feedback_b: The + here will be interpreted as addition since the methods return ints.
164+
:feedback_b: The divide function does integer division.
165165
:feedback_c: The + here will be interpreted as addition since the methods return ints.
166166
:feedback_d: The square and divide methods are called and return values that are added together.
167167
:feedback_e: Try the code in an active code window.
@@ -184,7 +184,7 @@ When calling the ``square`` method, the return value can be stored in a variable
184184
185185
public static void main(String[] args)
186186
{
187-
System.out.println(square(3) + divide(6,2));
187+
System.out.println(square(3) + divide(5,2));
188188
}
189189
}
190190

_sources/Unit3-If-Statements/frq-game-score.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ Let's simplify the problem by first writing the code to add the points for ``lev
168168
.. mchoice:: frq_expression
169169
:answer_a: score += levelOnePoints
170170
:answer_b: score += levelOne.getPoints()
171-
:answer_c: score = levelOne.getPoints()
172-
:answer_d: score = levelOne.points
171+
:answer_c: score = score + Level.getPoints()
172+
:answer_d: score = Level.points
173173
:random:
174174
:correct: b
175-
:feedback_a: The goalReached() method is a non-static method of the Level class. You need to call it with an object of the class.
176-
:feedback_b: Correct, this calls the levelOne object's goalReached() method.
177-
:feedback_c: The goalReached()`` method is a non-static method of the Level class. You need to call it with an object of the class, not the class name.
178-
:feedback_d: The goalReached() method does not take an argument.
175+
:feedback_a: There is no levelOnePoints variable.
176+
:feedback_b: Correct, this adds levelOne's getPoints() to score.
177+
:feedback_c: The getPoints()`` method is a non-static method of the Level class. You need to call it with an object of the class, not the class name.
178+
:feedback_d: There is no points instance variable.
179179

180180
Which expression would add the points for ``levelOne`` into a variable called ``score``?
181181

0 commit comments

Comments
 (0)