Learning To Program with Robots: Java http://www.learningwithrobots.com/textbook
ID: 3866806 • Letter: L
Question
Learning To Program with Robots: Java http://www.learningwithrobots.com/textbook/PDFs/WholeThing.pdf
Written Exercises Evaluate the following Boolean exp on intersection (1, 5) facing north. There is a Wall immediately in front of it In cach case your answer will bc cither true or false a. this.getAvenue) > 0 b. this .getAvenue ( ) 5 c. this .getStreet() != 1 d. I (this.getstreet 1) c. this.frontIsClear) f. lthis.frontIsclear) g. 11this.frontIsClear () h. this. front!sclear () == false Consider the following if-else statements. Do they bchave the same way or differently? Justify your answer 4.1 ressions for a Robot. Assume the robot is 4.2 if (this.canPickThing)) fthis.turnRight() if (this.canPickThing)) f this.turnLeft) } else else this.turnLeft() this.turnRight );Explanation / Answer
4.1)
a) this.getAvenue()>0 gives false since it is not intersecting the (1.5) point.
b) this.getAvenue() <=5 gives true since it is intersecting (1,5)
c) this.getStreet() != 1 gives false since it is intersecting exactly point at 1
d) !(this.getStreet() == 1) gives false since it is intersecting exactly point at 1
e) this.frontIsClear() gives true since there is no obstacle (remember robot facing north direction)
f) !this.frontIsClear() gives false since there is no obstacle (remember robot facing north direction)
g) !!this.frontIsClear() gives true since there is no obstacle (remember robot facing north direction) and adding two !! conditions gives true
h) this.frontIsClear() == false gives false since this method returns integer value.
------------------------------------------------------------------------------------------------------------------------------------------------
4.2)
They behave pure opposite since in if condition user kept '!' condition, which actually made two codes oppsite behaviour.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.