I need help with understanding classes how they work and how interact.
Here is my code so, You can easily understand what is problem. I don't know how to make changes after I create an object with certain class.
Please help, I will really appreciate, Not waiting for solution just show the direction to dig.
Description of Programm:
- Patient Fees
Here are some suggestions:
• The names, parameters, and return types of each function and class member function should be decided in advance.
• The program will be best implemented as a multifile program. Write a program that computes a patient’s bill for a hospital stay. The different components of the program are
• The PatientAccount class will keep a total of the patient’s charges. It will also keep track of the number of days spent in the hospital. The group must decide on the hospital’s daily rate.
• The Surgery class will have stored within it the charges for at least five types of surgery. It can update the charges variable of the PatientAccount class.
• The Pharmacy class will have stored within it the price of at least five types of medication. It can update the charges variable of the PatientAccount class.
• The main program.
The main program will design a menu that allows the user to enter a type of surgery, enter one or more types of medication, and check the patient out of the hospital. When the patient checks out, the total charges should be displayed.
#include <iostream>
#include<string>
#include<iomanip>
#include "classes.h"
using namespace std;
class PatientAccount {
private:
float patientCharge;
public:
PatientAccount(float charge=0){
charge =patientCharge;
}
float getPatientCharge() {
return patientCharge;
};
void setPatientCharge(float charge) {
charge = patientCharge;
}
};
class Pharmacy {
private:
double medCharges;
public:
double getmedCharges(){
return medCharges;
}
void setmedCharges(double charges) {
charges=medCharges;
}
Pharmacy() {
double antibiotics = 10.00,
antInausea =20.00,
antiInflamatory =30.00,
lightPain = 40.00,
strongPain = 50.00;
int choice;
cout << "Here is the list of medications choose one you used! "<< endl;
cout<< "To exit press 0 \n" <<endl;
do {
cout<<"(1) Antibiotics \n"
"(2) Ant-Inausea \n"
"(3) Anti-Inflamatory \n"
"(4) Light Pain pills \n"
"(5) Strong Pain pills \n"
"(0) To EXIT" << endl;
cin>>choice;
switch (choice) {
case 1: {
double temp=getmedCharges()+antibiotics;
setmedCharges(temp);
break;}
case 2: {
double temp=getmedCharges()+antInausea;
setmedCharges(temp);
break;}
case 3:{
double temp=getmedCharges()+antiInflamatory;
setmedCharges(temp);
break;}
case 4:{
double temp=getmedCharges()+lightPain;
setmedCharges(temp);
break;}
case 5:{
double temp=getmedCharges()+strongPain;
setmedCharges(temp);
break;}
case 6:
choice = 0;
};
}
while(choice!=0);
}
};
int main() {
Pharmacy spends;
PatientAccount someone;
cout<< someone.getPatientCharge()<<" $"<<endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire