Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my question. plz help me to solve it! 1. Define the class Robot with properties and functions given in the UML diagram below:

Here is my question. plz help me to solve it!

image text in transcribed
1. Define the class Robot with properties and functions given in the UML diagram below: The robot moves in a xy-plain, its location on the xy-plain is the ordered pair (xLocation, yLocation). The Robot object has a cargo bed that is either full(true) or empty (false). The Robot can carry a single character in its cargo bed. [6pts]- L Robot +xlocation: int +ylocation: int +cargoBed: bool Hoad: char +Robot() +setX(x: int): void Robot(): constroutor set locations to zero, cargoBed to falseand load to '0' +setY(y: int): void moveTo(): sets the xLocation and yLocation of the Robot object +getX(): int printRobot(): displays the loaction of the Robot and the value of its cargoBoe and load *getY(): int setCargo(): true means the Robot has a load +setCargo(b: bool): void setLoad(): The Robot can carry a load of char type. sets load to some character, it also +getCargo(): bool set cargoBed to true as well +setLoad(l: char): void +getLoad(): char +move To(x: int, y: int): bool +printRobot(): void a) Implement all the functions given in the UML diagram. The Robot can only move one unit at a time in either left, right, up or down directions. The moveTo(int x, int y) function checks the current position of the Robot at (xLocation, yLocation) then using loops moves the Robot ( one unit at a time) to the new location given by parameters x and y. [7pts]~ b) Write a main function in which a dynamic array of three Robot objects is created and populated. Move the Robots to different locations and assign different loads to them. Print the Robots. [6pts]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions