Which of these define a deposit
method? Check all that apply
function deposit(account, amount) { account.balance += amount }
let account = { balance: 0, deposit: function(amount) { this.balance += amount } }
let account = { balance: 0, deposit(amount) { this.balance += amount } }
let account = { balance: 0, deposit: amount => { this.balance += amount } }
When using the class
syntax to define a JavaScript class, where are the methods stored? Check all that apply.
In the “hard objects” technique, where are instance variables stored? Check all that apply.
lab16
subdirectory of your personal repo, the other submits a file report.txt
in the lab16
subdirectory of your personal repo.createCircleNode(x, y, size, color)
that returns an object with a single method getBounds
. The getBounds
method should return an object { x: ..., y: ..., width: ..., height: ... }
. (Look into ch08/graphed2/CircleNode.java
for guidance.)getBounds
method.contains
method that accepts a parameter p
of the form { x: ..., y: ...}
. The condition is (x + size / 2 - p.x) ** 2 + (y + size / 2 - p.y) ** 2 <= size ** 2 / 4
contains
method.class
syntax. Provide a constructor that produces an empty graph.add
method that adds a node, exactly like in ch08/graphed/Graph.java
findNode
method. Unlike lab 15, call contains
on the nodes.findNode
.createSquareNode
) or with the class
syntax.getBounds
and contains
.findNode
to a graph with a circle node and a square node.findNode
calls contains
on two node types. Is that polymorphism?