Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

In c + + 2 classes should be described: Class ProximitySensor consisting of fields: state ( on / off ) serial _ number methods: Constructor

In c++2 classes should be described:
Class ProximitySensor consisting of fields:
state (on/off)
serial_number
methods:
Constructor assigns serial number and off status
Get/Set state
bool Scan(area) returns whether there is an obstacle in front, area is an even(yes)/odd(not) number
PrintSensor outputs information about the sensor
Class iRobot consisting of fields:
model_name
LeftSenor
RightSensor
alarm (red/green)
string map which will consist of the symbols 'r'(right),'l'(left) and 'f'(front) depending on the direction
methods:
Constructor
SwitchOnOff turns on the robot by turning on both sensors
Run(room)-room is an int[10] array of numbers 10-99. 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[10] array with numbers 10-99. 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 'r','l','f' symbols depending on the information from the sensors. If the robot is able to clear the entire route map, a sequence of 10 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. 2 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

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