Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In c + + 2 classes should be described: Class ProximitySensor consisting of fields: state ( on / off ) serial _ number methods: Constructor
In c classes should be described:
Class ProximitySensor consisting of fields:
state onoff
serialnumber
methods:
Constructor assigns serial number and off status
GetSet state
bool Scanarea returns whether there is an obstacle in front, area is an evenyesoddnot number
PrintSensor outputs information about the sensor
Class iRobot consisting of fields:
modelname
LeftSenor
RightSensor
alarm redgreen
string map which will consist of the symbols rrightlleft and ffront depending on the direction
methods:
Constructor
SwitchOnOff turns on the robot by turning on both sensors
Runroomroom is an int array of numbers Fills map and alarm.
PrintRobot outputs the last robot route map and alarm status.
Process description. The robot can only be started with 'Run' if it is initially set to 'SwitchOnOff'. The "Run" method receives as a parameter the previously prepared int array with numbers The first digit provides information for the left sensor the second digit for the right. When processing the array sequentially, the map is filled with rlf symbols depending on the information from the sensors If the robot is able to clear the entire route map, a sequence of directions is formed, and the alarm receives the green status. If the robot is at a dead end both digits in the number are even the robot stops without completing the cleaning, without filling the map to the end, and receives the status red.
Test robots. robots must be assigned, one must be given a route without a dead end, the other with. You have to start cleaning, at the end call PrintRobot for both robots.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started