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...
Design a class named Message to represent a sentence or phrase. The class will contain: •...
Design a class named Message to represent a sentence or phrase. The class will contain: • a private string data field to hold the sentence or phrase. • A no-arg constructor with an empty string message. • A constructor that create a message object with the specified string sentence or phrase. • Accessor and mutator (getter/setter) for string data field. • A method named getVowels ( ) that returns the number of vowels in a sentence or phrase. • A...
Design a class named Account (put it in a package named accountspackages) with the following UML...
Design a class named Account (put it in a package named accountspackages) with the following UML diagram: Account -customerID: int -customerName: String -balance: double +setCustomerID(int): void +setCustomerName(String): void +setBalance(double):void +getCustomerID(): int +getCustomerName(): String +getBalance(): double +deposit(double): void +withdraw(double): void +printInformation():void The method withdraw(double) withdraws a specified amount from the account if the amount is less than or equal the balance, otherwise the method prints the message: Sorry! The account does not have sufficient funds. The method printInformation() prints:     the...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT