Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

#.. Use pythone 2. Create a class CRobotMobile that Inherits from CRobot It is further characterized by the integer attributes abs and ord which define

image text in transcribedimage text in transcribedimage text in transcribed

#.. Use pythone

2. Create a class CRobotMobile that Inherits from CRobot It is further characterized by the integer attributes abs and ord which define the position of the RobotMobile Has a method move(...) which allows the Robot to move forward according to its orientation if it moves east from x, the abscissa (abs ) increases by x if it moves west from x, the abscissa (abs ) decreases by x if it moves north from x, the ordinate (ord) increases by x if it moves south from x, the ordinate (ord) decreases by x Has a displayPosition() method that displays the position (coordinates). (a) Write a constructor without arguments of the CRobot Mobile class. (b) Write a four-argument constructor (type, sn, abs, ord) of the CRobotMobile class. (c) Redefine the method display() while using the parent class and the method displayPosition(). (d) Write a program that tests your CRobotMobile by performing the following actions: i. Turn East ii. Move West by 4 steps iii. Go North 6 steps . iv. Move 14 steps to East v. Move back 8 steps to the South 1 2 3 4 5 # create a dictionary for the directions of move direction - = { "North" 1, "East" : 2, "South" : 3, "West" : 4 } 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 # Create a robot robot - CRobotMobile) robot.display() # Orientation to the East robot.setOrientation direction [ "East"]) robot. display ( ) # Orientation to the Weat robot.setOrientation (direction"West"]) robot.move(4) robot.display() # Orientation to the North robot.setOrientation (direction[ "North"]) robot.move(6) robot.display() # Orientation to the East robot.setOrientation (direction[ "East"]) robot.move(14) robot.display ( ) # Orientation to the South robot.setOrientation (direction [ "South"]) robot.move(-8) robot.display() 22 23 24 25 26 27 28 29 30 31 Serial number : FOFO State : False Orientation : 1 Type : Mobile X: 0 Y: 0 Serial number : FOFO State : False Orientation : 2 Type : Mobile X: 0 Y: 0 Serial number : FOFO State : False Orientation : 4 Type : Mobile X: 0 Y: 0 Serial number : FOFO State: False Orientation : 1 Type : Mobile X: 0 Y: 6 Serial number : FOFO State : False Orientation : 2 Type : Mobile 0 Y: 6 Serial number : FOFO State : False Orientation : 3 Type : Mobile 0 14

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions