Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is not to be done using stdio.h library and should use iostream, I need help understanding how the classes work for C + +

This is not to be done using stdio.h library and should use iostream, I need help understanding how the classes work for C++ specifically. I understand enough about the syntax of C but have been having issues with the constructor/ class objects on the C++ side. Thanks!
1) Write a complete program utilizing the class Patient. The Patient class is used to track
patient information in a healthcare environment. See the table below for details on each
member of the class and its description.
Patient Class
Private members Description
string m_name Stores the patients name
int m_age Integer to store patients age in years
double m_weight double to store patients weight in kilograms
bool m_admitted Boolean variable to store whether or not patient is
currently admitted into hospital (true/false)
int m_location integer to store patient room number. If patient is not
admitted then room number should be -1
Public members Description
Patient() Default constructor for patient class. The constructor
should initialize the patients location to -1 and the
m_admitted variable to false.
Patient(string name, int age) Constructor to allow name and age to be initialized
during object creation. The constructor should
initialize the patients location to -1 and the
m_admitted variable to false.
setWeight(double weight) A member function to allow assignment of patients
weight in kilograms
printInfo() A member function that displays all information about
patient. An example is shown below. You do not need
to worry about number of decimal points shown.
admitPatient(int location) A member function to admit a patient into the
hospital. The function should accept the room number
(location) as an input parameter, then pass this into
the internal object data and the function should also
change the m_admitted variable to true.
releasePatient() A member function to release a patient from the
hospital. The function should change the patient
location to -1, and should change the m_admitted
variable to false
An example format for the printInfo() function is:
Patient Info:
----------------------------------
Name: Billy Bronco
Age: 21
Weight: 81.3000 kg
Admitted?: Yes
Room #: 321
Patient Info:
----------------------------------
Name: John Doe
Age: 34
Weight: 67.5500 kg
Admitted?: No
Room #: N/A
Note that the printInfo() function will need to check the m_admitted variable for true/false
and then print Yes/No based on that. Also, if the patient m_location is -1, the function will
print N/A instead of -1.
2) Inside of main() you will need to create two Patient objects and demonstrate the
functionality of the class. Please create two Patient objects and use the constructor to
initialize the name and age of each of the two patients. Use the setWeight() function
assign a body weight to each patient (in kilograms). Now, print the information for each
patient. Finally, use the admitPatient() function to admit one of your two patients and you
can make up any room number you like. Print the info for that patient to show that the
admitPatient() function has worked correctly. Now, use the releasePatient() function and
then print the info again to show that the data inside the object has changed appropriately.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions