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...
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)...
Design a class named Account that contains: A private String data field named accountNumber for the...
Design a class named Account that contains: A private String data field named accountNumber for the account (default AC000). A private double data field named balance for the account (default 0). A private double data field named annualIntRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. A private Date data field named dateCreated that stores the date when the account was created. A no-arg constructor that creates a default account. A constructor...
Design a class named BankAccount that contains: A private int data field named id for the...
Design a class named BankAccount that contains: A private int data field named id for the account. A private double data field named balance for the account. A constructor that creates an account with the specified id and initial balance. A getBalance() method that shows the balance. A method named withdraw that withdraws a specified amount from the account. Create a subclass of the BankAccount class named ChequingAccount. An overdraftlimit to be 1000 for ChequingAccount . Test your ChequingAccount class...
Design a class named Account that contains: ■ A private int data field named id for...
Design a class named Account that contains: ■ A private int data field named id for the account (default 0). ■ A private double data field named balance for the account (default 0). ■ A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. ■ A private Date data field named dateCreated that stores the date when the account was created. ■ A no-arg constructor that creates...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT