Question: code: // // Angle.h // #ifndef ANGLE_H #define ANGLE_H class Angle { private: int theta; void set(int t); public: Angle(void); int get(void); void change(int dt);

code:
// // Angle.h //
#ifndef ANGLE_H #define ANGLE_H
class Angle { private: int theta; void set(int t);
public: Angle(void); int get(void); void change(int dt); void print(void); }; #endif
//
// robot.cpp
//
#include "Angle.h"
#include
using namespace std;
int main()
{
Angle a;
a.print();
a.change(15); a.print();
a.change(10); a.print();
a.change(-120); a.print();
a.change(-5); a.print();
a.change(0); a.print();
a.change(60); a.print();
a.change(-135); a.print();
a.change(1); a.print();
a.change(-1); a.print();
a.change(1); a.print();
a.change(-10); a.print();
a.change(50); a.print();
a.change(150); a.print();
a.change(-30); a.print();
a.change(10);
cout
}
robot.out
angle: 30 angle: 45 angle: 55 angle: -65 angle: -70 angle: -70 angle: -10 angle: -120 angle: -119 angle: -120 angle: -119 angle: -120 angle: -70 angle: 60 angle: 30 40
Description The position of a robotic arm is determined by an angle that can only take values between -120 degrees and +60 degrees (included). In this homework, you will create a C++ class Angle that represents the angle of the robotic arm. The implementation should enforce the limits on the range of allowed values. The angle can only take integer values. Any attempt to change the angle beyond a limit should result in the angle value being that limit. For example, any attempt to change the angle to a value smaller than -120 should result in the angle value being -120. The class Angle includes a public member function change (int dt) and a private member function set(int t). The change function uses the set function to change the angle by the amount dt. The argument dt may be positive or negative. The initial angle value at the time the robotic arm is powered up is 30 degrees. The Angle object should set its angle value to be 30 when the object is created. See the file Angle.h for details and other member functions. The Angle class is used by a program robot.cpp that is provided. The output of the program robot must reproduce exactly the contents of the file robot.out. The files Angle.h and robot.cpp are provided and must not be modified. You must create a file Angle.cpp containing the implementation of your Angle class. It must be possible to compile the program robot.cpp to generate an executable named robot using the command: make without generating any warning message. The Angle class that you provide will also be compiled and linked with another program that uses the Angle member functions when grading the assignment. You must create a Makefile that contains a target robot and a target clean. The target robot should appear first and will be used to build the executable robot. The target clean will be used to remove all object files and executables. The Makefile should include the necessary definition to compile C++ files using g++ with the -Wall option
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
