Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ ONLY: ASSIGNMENT: WRITE THE FUNCTION FOR THE FOLLOWING: ROBOT101( ); ROBOT101(GRID g, POINT startAt, int startPower); string getID(); void set_ID(string ID); void ShowID(); File

C++ ONLY: ASSIGNMENT: WRITE THE FUNCTION FOR THE FOLLOWING:  ROBOT101( ); ROBOT101(GRID g, POINT startAt, int startPower); string getID(); void set_ID(string ID); void ShowID(); File name: robot101class.h robot101class.cpp test_robot101class.cpp Givens: OP repository. bbs_ROBOT101_class -- class diagram (use to code robot101class.h, and implementation robot101class.cpp) starter-test_robot101class.cpp -- sample test program for testing the ROBOT101class. key-robot101class.o -- correct class implementation (use to test your test program while other group members implement ROBOT101class. To use: you need your robot101class.h file > g++ yourtest.cpp key-robot101class.o -o trc > ./trc Description: Write program to simulate the movement of a robot on a 2-dimensional grid (xMin,yMin) to (xMax, yMax). Simple moves of distance one are supported: L R U D (left). Each attempted move consumes 1 unit of power. The robot is positioned on the grid, then powered on (and given its ID, its power level, the grid dimensions, and its starting position). If the start position is off the grid, the robot issues a message and sets the start position to (0,0). The robot can not leave the grid. For any move that attempts to leave the grid, the robot must report "BAD MOVE to POSITION (xbad,ybad)" but not perform the move. (The attempt DOES consume 1 unit of power.) The robot turns itself off (is no longer active) when the power level falls to zero following a move, or when a shut-down command is processed. All moves are denied when the robot in INACTIVE. The robot controller (a main programi -- PROG7) enables a user to command the robot through keyboard commands: Start (S): 1. read the following from keyboard: - robot ID (a string) - initial power level - grid dimensions (xMin, yMin) (xMax, yMax) - starting position (x, y). 2. - Activate the robot and initialize its with the information in step 1. The robot controller must respond to these commands: WhereIam (W) -- display its current (x,y) grid location. Movement (L, R, U, D) -- each move consumes one unit of power. Power (P) -- display the remaining power level. Terminate(T) --report current position and terminate. Moves (M) -- list the sequence of valid moves. Raw Distance Moved (r) -- display total distance moved. Net Distance Moved (n) -- display net distance traveled from start position to current position. 

CLASS DIAGRAM FILE

#ifndef GRID_POINT #define GRID_POINT struct POINT { int x; int y; POINT(int Xcoord, int Ycoord){x=Xcoord; y=Ycoord;} POINT(){x=0; y=0;} }; struct GRID { POINT gridMIN, gridMAX; GRID(){POINT temp; gridMIN = temp; gridMAX=temp;} GRID(POINT xymin, POINT xymax) { gridMIN = xymin; gridMAX = xymax; } }; #endif ROBOT101 +------------------------------------------------------+ | class ROBOT101 | | | |-----------------+ | | ROBOT101( ) | | |--------------------------------------------------+ | | ROBOT101(GRID g, POINT startAt, int startPower) | | |--------------------------------------------------+ | |---------------------+ +-------------------------| | string getID() | | void set_ID(string ID) | |---------------------+ +-------------------------| | void ShowID() | | void ShowStartPosition()| |---------------------+ +-------------------------| | bool isActive() | |void ShowGridDimensions()| |---------------------+ +-------------------------| | void ShutDown() | | |---------------------+ | | | |-----------------+ +-------------------------| | void MoveLeft() | | void MoveRight() | |-----------------+ +-------------------------| | void MoveUp() | | void MoveDown() | |-----------------+ +-------------------------| | | |-----------------+ +-------------------------| | int NumMoves() | | void ShowMoves() | |-----------------+ +-------------------------| | int Power() | | void ShowPower() | |-----------------+ +-------------------------| | | |---------------------+ +-------------------------| | POINT getPosition() | | void ShowPosition() | |---------------------+ +-------------------------| | int RawDistance() | | void ShowRawDistance() | |---------------------+ +-------------------------| | float NetDistance() | | void ShowNetDistance() | |---------------------+ +-------------------------| | | | | | +-----------------------------------+ | | | GRID grid; | | | +-----------------------------------+ | | | bool Active | | | +-----------------------------------+ | | | string robotID | | | +-----------------------------------+ | | | POINT startPosition; | | | +-----------------------------------+ | | | POINT curPosition; | | | +-----------------------------------+ | | | int powerLevel; | | | +-----------------------------------+ | | | int validMoves; | | | +-----------------------------------+ | | | vector Moves; | | | +-----------------------------------+ | | | | | +------------------------------------------------------+

ROBOT101CLASS.H FILE

#include  #include  #include  #include  #include  using namespace std; #ifndef GRID_POINT #define GRID_POINT struct POINT { int x; int y; POINT(int Xcoord, int Ycoord){x=Xcoord; y=Ycoord;} POINT(){x=0; y=0;} }; struct GRID { POINT gridMIN, gridMAX; GRID(){POINT temp; gridMIN = temp; gridMAX=temp;} GRID(POINT xymin, POINT xymax) { gridMIN = xymin; gridMAX = xymax; } }; #endif class ROBOT101 { private: string robotID; POINT startPos; POINT curPos; GRID grid; int powerLevel; bool Active; int validMoves; vector Moves; //----------------------------------------------// public: ROBOT101(); ROBOT101(GRID g, POINT startAt, int startPower); bool isActive(); void ShutDown(); void set_ID(string ID); string getID(); void ShowID(); void ShowGridDimensions(); void ShowStartPosition(); POINT getPosition(); void ShowPosition(); void MoveLeft(); void MoveRight(); void MoveUp(); void MoveDown(); int NumMoves(); void ShowMoves(); int Power(); void ShowPower(); int RawDistance(); void ShowRawDistance(); void ShowNetDistance(); float NetDistance(); }; //class ROBOT101 

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

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

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

1. What are the major sources of stress in your life?

Answered: 1 week ago