1/14
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Your implementation must follow all rules in STATEMENT_MODEL. If your code breaks any rule, the implementation is wrong.
What does StatementKernel modeled by STATEMENT_MODEL mean?
A default BLOCK statement with an empty body: compose((BLOCK, ?, ?), <>)
What does the no-argument constructor new Statement1() create?
STATEMENT_MODEL says test and call are irrelevant when kind is BLOCK — we don't know or care about their values.
Why are the 2nd and 3rd tuple components ? when kind is BLOCK?
Returns the kind/label of the current statement (e.g. BLOCK, IF, WHILE, CALL).
What does this.kind() do?
Inserts statement s at position pos inside a BLOCK statement.
What does addToBlock(int pos, Statement s) do?
Removes and returns the statement at position pos from a BLOCK statement.
What does removeFromBlock(int pos) do?
The number of statements currently inside a BLOCK statement.
What does lengthOfBlock() return?
Builds an IF statement from condition c and body block s. Result: compose((IF, c, ?), )
What does assembleIf(Condition c, Statement s) do?
Breaks apart an IF statement — returns the condition and puts the body block into s. Opposite of assembleIf.
What does disassembleIf(Statement s) do?
addToBlock, removeFromBlock, and lengthOfBlock. Using them on non-BLOCK statements violates STATEMENT_MODEL.
Which methods only work on BLOCK statements?
The abstract mathematical rulebook your implementation must satisfy — defines what each method must do.
What is STATEMENT_MODEL in simple terms?
1st = kind (IF), 2nd = test (condition), 3rd = call (associated call). Body statements are in .
In compose((IF, test, call), ) what do the 3 tuple components represent?
BLOCK is the simplest blank state — IF and WHILE require meaningful test and call values to be valid.
Why does the no-argument constructor default to BLOCK and not IF or WHILE?
s gets replaced with the body block of the IF statement that was disassembled.
What happens to s after calling disassembleIf(Statement s)?
They are inverses — assembleIf builds an IF statement from parts, disassembleIf breaks it back into those parts.
What is the relationship between assembleIf and disassembleIf?