Question

In: Computer Science

Design and define a class named Heart Monitor Station. The Heart Monitor station monitors the average...

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

  • an array of dynamically allocated elements of type float that holds the daily heart beat averages.
  • a non-negative integer that stores the maximum number of daily heart beat averages that the Heart Monitor station can record.
  • a non-negative integer that stores how many instances of Type Heart Monitor Station exist in the program (were created but not destroyed)

A Heart Monitor Station object can be created in any one of these ways:

  • Default Constructor sets the maximum number of heart beat records to 50.
  • 1-argument Constructor specifies the maximum number of heart beat records that an instantiated Heart Monitor station object can hold. When a Heart Monitor Station object is created, an array of dynamically allocated Heart Beat Records must be created.
  • Copy Constructor
  • Move Constructor

Public Member Functions

  • numHeartStations returns how many instances of Type Heart Monitor Stations exist in the program(were created but not destroyed)
  • maxSize returns the maximum number of heart beat records that the Heart Station can carry

This will be done using C++

Solutions

Expert Solution

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.


Related Solutions

Design a class named Fan to represent a fan. The class contains: ■ Three constants named...
Design a class named Fan to represent a fan. The class contains: ■ Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. ■ A private int data field named speed that specifies the speed of the fan (the default is SLOW). ■ A private boolean data field named on that specifies whether the fan is on (the default is false). ■ A private double data field named radius that specifies...
In Java, design a class named MyInteger. The class contains: An int data field named value...
In Java, design a class named MyInteger. The class contains: An int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int A get method that returns the int Methods isEven(), isOdd(), and isPrime() that return true if the value is even, odd, or prime, respectively. Static methods isEven(int), isOdd(int), and isPrime(int) that return true if the specified value is even, odd, or prime, respectively. Static...
Python Please (The Fan class) Design a class named Fan to represent a fan. The class...
Python Please (The Fan class) Design a class named Fan to represent a fan. The class contains: ■ Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. ■ A private int data field named speed that specifies the speed of the fan. ■ A private bool data field named on that specifies whether the fan is on (the default is False). ■ A private float data field named radius that...
Create a class named GameCharacter to define an object as follows: The class should contain class...
Create a class named GameCharacter to define an object as follows: The class should contain class variables for charName (a string to store the character's name), charType (a string to store the character's type), charHealth (an int to store the character's health rating), and charScore (an int to store the character's current score). Provide a constructor with parameters for the name, type, health and score and include code to assign the received values to the four class variables. Provide a...
c++ E2b: Design a class named Rectangle to represent a rectangle. The class contains:
using c++E2b: Design a class named Rectangle to represent a rectangle. The class contains:(1) Two double data members named width and height which specifies the width and height of the rectangle .(2) A no-arg constructor that creates a rectangle with width 1 and height 1.(3) A constructor that creates a rectangle with the specified width and height .(4) A function named getArea() that returns the area of this rectangle .(5) A function named getPerimeter() that returns the perimeter of this...
Put In Java Programming The TicketMachine class: Design a class named TicketMachine that contains: • A...
Put In Java Programming The TicketMachine class: Design a class named TicketMachine that contains: • A double data field named price (for the price of a ticket from this machine). • A double data field named balance (for the amount of money entered by a customer). • A double data field named total (for total amount of money collected by the machine). • A constructor that creates a TicketMachine with all the three fields initialized to some values. • A...
Following the example of Circle class, design a class named Rectangle to represent a rectangle. The...
Following the example of Circle class, design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. A no-arg constructor that creates a default rectangle. A constructor that creates a rectangle with specified width and height A method name getWidth() return the value of width A method named getHeight() returns value of...
PUT IN JAVA PROGRAMMING The Stock class: Design a class named Stock that contains: • A...
PUT IN JAVA PROGRAMMING The Stock class: Design a class named Stock that contains: • A string data field named symbol1 for the stock’s symbol. • A string data field named name for the stock’s name. • A double data field named previousClosingPrice that stores the stock price for the previous day. • A double data field named currentPrice that stores the stock price for the current time. • A constructor that creates a stock with the specified symbol and...
Following the example of Circle class, design a class named Rectangle to represent a rectangle. The...
Following the example of Circle class, design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. A no-arg constructor that creates a default rectangle. A constructor that creates a rectangle with specified width and height A method name getWidth() return the value of width A method named getHeight() returns value of...
Design a class named Account that contains: A private int data field named id for the...
Design a class named Account that contains: A private int data field named id for the account. A private double data field named balance for the account. A private double data field named annualInterestRate that stores the current interest rate. A no-arg constructor that creates a default account with id 0, balance 0, and annualInterestRate 0. The accessor and mutator methods for id, balance, and annualInterestRate. A method named getMonthlyInterestRate() that returns the monthly interest rate. A method named withdraw(amount)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT