Hi
this is my question , and I have some error in my code ,and I cant correct them ,and I am asking if you could help me ?
this is the question :
Create a class called BloodDonor that maintains information about blood donors in a blood bank having the following data members:
1. IdNumber, // long int
2. name, //Name of donor
3. bloodGroup//String
4. home_Phone//String
5. mobile_Phone//String
6. address // struct Address that holds int house number, int road number, int block
number, string city, and string country
It will also have the following member functions:
1. Constructor function with default values IdNumber = 0, name = "", bloodGroup = "",
home_Phone="", mobile_Phone="", address={0,0,0,"",""} An overloaded constructor that takes the same parameters of the constructor in except
Address for the address
2. Set and get functions for all data members. The setBloodgroup function should check
the validity of the blood group before assigning it to bloodGroup by calling the
function Is_BloodBroup_Valid described below.
3. Overloaded functions for setAddress one that takes an Address as parameter and the
other one takes int,int,int,string [], and string[] for address
4. Is_BloodBroup_Valid // takes a string as parameter and return true if it is a valid
group and false if not. The only possible blood groups are A+, A-, B+, B-, 0+, 0-,
AB+, AB-.
5. InputDetails// asks the user to enter all the details of a donor and then assign the
values to the data members by calling the appropriate set functions.
6. printDetails // Print the details (IdNumber,name, bloodGroup, home phone, mobile
phone, and address) of the donor
8. Destructor function.
PART A
Write the class BloodDonor including the code of the member functions.
PART B
Write a main function which includes the following:
1. Creates an instance (object) named donor1 of type BloodDonor with id=567JJ9, name is
Ahmed, blood group is B+, home phone="17123456", mobile phone="39999999",
address={ l,l,l,"Manama","Bahrain"}-
2. Write a statement to change the mobile phone to "39888888".
3. Write a statement to print the mobile phone.
4. Write a statement to print the details of donor.
5. Create another object named donor2 of type BloodDonor.
6. Ask the user to enter the details of the donor2 by calling InputDetails function
7. Print the details of donor2.

this is my code

#include<iostream>
#include<string>
using namespace std ;
struct Address {
	int house ,road ,block;
	string city,country;
};
class BloodDonor {
    private:
	long IdNumber;
	string name ;
	string bloodGroup;
	string home_Phone;
	string mobile_Phone;
	Address add;
	public:
		BloodDonor(int  id=0,string  nm=" ",string bldGrp=" ",string hmPHn=" ",string mblPhn ,Address add={0,0,0," "," "});
		BloodDonor(int  ,string  ,string,string );
		void getBloodgroup  ( long &id, string &nm, String &bldGrp, String &hmPHn,String &mblPhn );
		void setBloodgroup (  long IdNumber, string name, String bloodGroup, String home_Phone,String mobile_Phone);
		bool Is_BloodGroup_Valid (string bloodGroup);
		void setAddress(int h ,int r, int b, string c,string count );
		void setAddress(Address a);
		void InputDetails();
		void printDetails ();
		~ BloodDonor();
};
BloodDonor bldDnr;
void BloodDonor::setAddress(int h ,int r, int b, string c,string count ){
	add.house=h;
	add.road=r;
	add.city=c;
	add.country=count;
}
void BloodDonor::setAddress(Address a){
	add.house=a.house;
	add.road=a.road;
    add.city=a.city;
	add.country=a.country;
}


BloodDonor::~ BloodDonor(){
	cout<<" terminate objects";
}

void BloodDonor::InputDetails(){
	
	cout<<"Enter the donor details as follow "<<endl;
	cout<<"adress";
	cout<<"house";
	cin>>add.house;
	cout<<"road";
	cin>>add.road;
	cout<<"block";
	cin>>add.block;
	cout<<"city";
	cin>>add.city;
	cout<<"country";
	cin>>add.country;
	bldDnr.setAddress( add.house,add.road,add.block,add.city,add.country);


}
	
bool BloodDonor::Is_BloodGroup_Valid (string &bloodGroup){
	
		enum bloodType {A+,A-,B+,B-,AB+,AB-,O+,O-};
		switch (bloodGroup){
		case "A+":
			bloodGroup="A+";
		    break;
		case "A-":
			bloodGroup="A-";
		    break;
		case "B+":
			bloodGroup="B+";
			break;
		case "B-":
			bloodGroup="B-";
			break;
		case AB+:
			bloodGroup="AB+";
			break;
		case "AB-":
			bloodGroup="AB-";
			break;
		case "O+":
			bloodGroup="O+";
			break;
		case "O-":
			bloodGroup="O-";
			break;
			return true;
		default :
			return false;

}
		void BloodDonor::setBloodgroup(  long IdNumber, string name, String bloodGroup, String home_Phone,String mobile_Phone){
			
	id=IdNumber;
    nm=name;
    bldGrp=bloodGroop;
    hmPHn=home_Phone;
    mblPhn=mobile_Phone;
}				
	void BloodDonor::getBloodgroup(long  &id, string &nm, String &bldGrp, String &hmPHn,String &mblPhn){
IdNumber=id;
name=nm;
bloodGroop=bldGrp;
home_Phone=hmPHn;
mobile_Phone=mblPhn;
bldDnr.Is_BloodGroup_Valid(bldGrp
		}
	void BloodDonor::printDetails(){
			bldDnr.setBloodgroup()
			cout<<"Id"<<IdNumber<<endl;
			cout<<"Blood Groop"<<bloodGroop<<endl;
			cout<<"home_Phone"<<home_Phone<<endl;
            cout<<"mobile_Phone"<<mobile_Phone<<endl;
}				

int main(){
	BloodDonor donor1 (567889,Ahmed,B+,"17123456","39999999",111,Manama,Bahrain);
	BloodDonor donor2;
	BloodDonor donor1 (567889,Ahmed,B+,"17123456","39888888",111,Manama,Bahrain);
	donor1.printDetails();
	donor2.InputDetails();
	donor2.printDetails();


	return 0;
}

	


}

>>and I have some error in my code ,and I cant correct them
I just got new glasses the other day but I'm still having problems seeing the errors you get on your monitor. So would you post them here to make them easier to read ?

commented: I just got new glasses the other day but I'm still having problems seeing the errors you get on your monitor. <=> LOL +1

You have many many errors in your code. Are there any errors in particular that you're having trouble understanding?

you don't need the line: BloodDonor bldDnr; or any reference to bldDnr

your enum bloodType tries to use invalid characters as variable/enumeration names. Try using allowable names.

setting the default address struct value should can be done like this:

    BloodDonor(int  id=0,string  nm=" ",string bldGrp=" ",string hmPHn=" ",string mblPhn ,Address add=(struct Address){0,0,0," "," "});

Note the casting.

oooh, the list goes on. Use your compiler generated errors to pinpoint where you're going wrong and fix the code 1 line at a time. Eventually there will be no errors.

Great.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.