In: Computer Science
Design and define a class named Heart Monitor Station. The Heart Monitor station monitors the average daily heart beats and keeps record of historical data. The measurement is taken and stored on a daily basis.
Basic Details
Your Heart Monitor Station class has the following data members
A Heart Monitor Station object can be created in any one of these ways:
Public Member Functions
This will be done using C++
Code
#include<iostream>
using namespace std;
class HeartMonitorStation
{
public:
static int countStation;
HeartMonitorStation();
HeartMonitorStation(int);
HeartMonitorStation(const HeartMonitorStation
&);
HeartMonitorStation(HeartMonitorStation&&);
int numHeartStations();
int maxSize();
private:
float * heart_beat_averages;
int max;
};
// integer that stores how many instances of Type Heart Monitor
Station exist in the program
int HeartMonitorStation::countStation;
//Default Constructor sets the maximum number of heart beat records
to 50.
HeartMonitorStation::HeartMonitorStation()
{
max = 50;
heart_beat_averages = new float[max];
countStation++;
}
//1-argument Constructor
HeartMonitorStation::HeartMonitorStation(int size)
{
max = size;
heart_beat_averages = new float[max];
countStation++;
}
//Copy Constructor
HeartMonitorStation::HeartMonitorStation(const HeartMonitorStation
& other)
{
this->max = other.max;
heart_beat_averages = new float[max];
for (int i = 0; i < max; i++)
this->heart_beat_averages[i] =
other.heart_beat_averages[i];
countStation++;
}
//Move Constructor
HeartMonitorStation::HeartMonitorStation(HeartMonitorStation&&
other)
{
this->max = other.max;
heart_beat_averages = new float[max];
for (int i = 0; i < max; i++)
this->heart_beat_averages[i] =
other.heart_beat_averages[i];
other.heart_beat_averages = nullptr;
}
//returns how many instances of Type Heart Monitor Stations exist
in the program(were created but not destroyed)
int HeartMonitorStation::numHeartStations()
{
return countStation;
}
// returns the maximum number of heart beat records that the Heart
Station can carry
int HeartMonitorStation::maxSize()
{
return max;
}
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.