Given below is the code for the question. Please do rate the answer if it helped. Thank you.
Bug.hpp
======
#ifndef BUG_HPP
#define BUG_HPP
class Bug
{
private:
int position;
int dir;
public:
Bug();
Bug(int pos);
void move();
void turn();
void display();
};
#endif
Bug.cpp
======
#include "Bug.hpp"
#include <iostream>
using namespace std;
Bug::Bug(){
position = 0;
dir = 1;
}
Bug::Bug(int pos){
position = pos;
dir = 1;
}
void Bug::move(){
position = position + dir;
}
void Bug::turn(){
dir = -dir;
}
void Bug::display(){
cout << "position = " << position <<
", direction = " << dir << endl;
}
TestBug.cpp
=======
#include <iostream>
#include "Bug.hpp"
using namespace std;
int main(){
Bug b(10);
b.display();
b.move();
b.display();
b.turn();
b.display();
b.move();
b.display();
return 0;
}

C++ IJU U Construct a user-defined object class named Bug that models a bug moving along...
Python Write a class bug that models a bug moving along a horizontal line. The bug moves either to the right to left. Initially, the bug moves to the right, but it can turn to change its direction. In each move, its position changes by one unit in the current direction. Provide a constructor def__init__(self, initial position) and methods . def turn(self) . def move(self . def getposition(self) Sample usage: bugsy = bug(10) bugsy.move() # Now the position is 11...
** MUST BE PROGRAMMED IN PYTHON** Thank you. 1. Write a class bug that models a bug moving along a horizontal line. The bug moves either to the right to left. Initially, the bug moves to the right, but it can turn to change its direction. In each move, its position changes by one unit in the current direction. Provide a constructor def__init__(self, initial position) and methods . def turn(self) . def move(self . def getposition(self) Sample usage: bugsy =...
*using c++* Construct a class named Savings containing three floating-point data members named balance, rate, and interest and a constructor that initializes each data member to 0. This class should be established with typical two files(.h and .cpp). Include a member function that inputs a balance and rate and then calculates an interest. The rate should be stored as a percent, such as 6.5 for 6.5%, and the interest is computed as interest = (balance)(rate/100). Add a member function to...
Construct a C++ class named Rectangle that has floating-point data members named length and width. The class should have a zero-argument constructor that initializes each data member to 0. It should have member functions named calcPerimeter() and calcArea() that calculate the perimeter and area of a rectangle respectively, a member function setLength() and setWidth() to set the length and width, member functions getLength() and getWidth() to return the length and width, and a member function showData() that displays the rectangle’s length,...
Construct a class named Room that declares two double-precision data members named length and width (2 points). Include a constructor that initializes each data member to 1.0 when a Room object is created (1 point). Add two accessor functions for displaying the length and width values of a Room object and two mutator functions that allow changing these data member values. (2 points) Write a program that tests all functionality of this class. (3 points) Extra Credit: Create this class...
C++ PRPGRAM- double-linked lists Create the .h and .cpp files for an Element class that contains the data and pointers for a double-link list for this application. Your linked list must consist of objects of this class. The class should contain at least the following elements (you may have more if you wish): The standard four constructors (default, parameterized, copy, move) The standard assignment operators (copy, move) A destructor Stream operators (<< and >>) The standard relational operators (<, <=,...
Objectives:
1. Classes and Data Abstraction?2. User-defined classes?3.
Implementation of a class in separate files
Part 1:
In this assignment, you are asked:
Stage1:?Design and implement a
class named memberType
with the following requirements:
An object of memberType holds the following
information: • Person’s first name (string)?• Person’s last name
(string)?• Member identification number (int)
• Number of books purchased (int)?• Amount of money spent
(double)?The class memberType has member functions that
perform operations on objects of memberType. For the...
Need helps on C++ attach. Thanks
Pointers with classes a) A user-defined class named Timer has a constructor that takes two integer parameters to initialize hour and minute data members. Write a single C++ statement to create an object of the Timer class using dynamic memory allocation and assign it to a pointer variable named timePt r. It should call the constructor with two parameters. Use values of 10 and 20 for hour and minute respectively. b) Write the definition...
Create a class named BankAccount with data fields for a count number and a balance. Include a constructor that takes arguments for each field. The constructor sets the balance to 0 if it is below the required $200.00 minimum for an account. Include a method that displays the account details, including an explanation if the balance was reduced to 0. Write the class TestAccount in which you instantiate two BankAccount objects, prompt a user for values of the account number...
C++ Language I have a class named movie which allows a movie object to take the name, movie and rating of a movie that the user inputs. Everything works fine but when the user enters a space in the movie's name, the next function that is called loops infinetly. I can't find the source of the problem. Down below are my .cpp and .h file for the program. #include <iostream> #include "movie.h" using namespace std; movie::movie() { movieName = "Not...