This program I have to solve it before next week;so plezzzzz plezzzz help me
And I will be very happy if I solve it
:)
:)

ITCS102
Assignment #4(chapter 12)

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, maximum 20 Characters
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,””,””} which is passed as int,int,int,char[], and char[]
2. An overloaded constructor that takes the same parameters of the constructor in except Address for the address
3. 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.
4. Overloaded functions for setAddress one that takes an Address as parameter and the other one takes int,int,int,char [], and char[] for address
5. 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-, O+, O-, AB+, AB-.
6. 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.
7. printDetails // Print the details (IdNumber,name, bloodGroup, home phone, mobile phome, 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=56789, name is Ahmed, blood group is B+, home phone=“17123456”, mobile phone=”39999999”, address={1,1,1,”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. Creates another object named donor2 of type BloodDonor.
6. Ask the user to enter the details of the donor2 and store them in the object.
7. Print the details of donor2


I had only done part A but I have lots of midterms at those days so I do not have time to finish this program
plezzzz I wander if any body help

Recommended Answers

All 8 Replies

Nobody is going to do your homework for you without pay. Put $1,000.00 USD in my paypal account and I'll write it for you.

Otherise, post what you have done and we'll go from there.

I think I have that assignment done lmao here let me look.

what is it supposted to be saved as?

he give me $1,000.00 USD on paypal :P
[main.cpp]

#include <iostream>
#include "BloodDonor.h"
#include "Address.h"
using namespace std;

int main(int argc, char **argv) {
	Address adr(1,1,1,"Manama","Bahrain");
	BloodDonor donor1(56789, "Ahmed", "B+", "17123456", "39999999", adr  );
	donor1.set_mobile_Phone("39888888");
	cout << donor1.get_mobile_Phone() << endl;
	donor1.printDetails();
	BloodDonor donor2;
	donor2.InputDetails();
	donor2.printDetails();
	return 0;
}

[Address.h]

#ifndef ADDRESS_H_
#define ADDRESS_H_
#include <string>
using namespace std;
struct Address {
	int _house_number;
	int _road_number;
	int _block_number;
	string _city;
	string _country;
	Address(int house_number = 0, int road_number = 0, int block_number = 0,
			char* city = "", char* country = "") :
		_house_number(house_number), _road_number(road_number),
				_block_number(block_number), _city(city), _country(country) {
	}
};

#endif /*ADDRESS_H_*/

[BloodDonor.h]

#ifndef BLOODDONOR_H_
#define BLOODDONOR_H_
#include <string>
#include "Address.h"
using namespace std;



class BloodDonor {
	long int _IdNumber;
	char _name[21];
	string _bloodGroup;
	string _home_Phone;
	string _mobile_Phone;
	Address _address;

public:
	BloodDonor(int _IdNumber = 0, char* name = "", string bloodGroup = "",
			string home_Phone="", string mobile_Phone="");
	BloodDonor(int _IdNumber, char* name, string bloodGroup,
			string home_Phone, string mobile_Phone,
			Address address);
	~BloodDonor();
	long int get_IdNumber();
	string get_name();
	string get_bloodGroup();
	string get_home_Phone();
	string get_mobile_Phone();

	void setAddress(int house_number, int road_number, int block_number,
			char* city, char* country);
	void setAddress(Address*);
	void set_IdNumber(int);
	void set_name(char*);
	void set_bloodGroup(string);
	void set_home_Phone(string);
	void set_mobile_Phone(string);
	bool Is_BloodBroup_Valid(string);
	void InputDetails();
	void printDetails();
};

#endif /*BLOODDONOR_H_*/

[BloodDonor.cpp]

#include "BloodDonor.h"
#include <iostream>

BloodDonor::BloodDonor(int IdNumber, char name[21], string bloodGroup,
		string home_Phone, string mobile_Phone, Address address) :
			//(int house_number,int road_number,int block_number,char* city, char* country) = 0
			_IdNumber(IdNumber), _bloodGroup(bloodGroup),
			_home_Phone(home_Phone), _mobile_Phone(mobile_Phone) {
	strcpy(_name, name);
	setAddress(&address);
}
BloodDonor::BloodDonor(int IdNumber, char* name, string bloodGroup,
		string home_Phone, string mobile_Phone) :
	_IdNumber(IdNumber), _bloodGroup(bloodGroup), _home_Phone(home_Phone),
			_mobile_Phone(mobile_Phone) {
	strcpy(_name, name);
}
BloodDonor::~BloodDonor() {

}

void BloodDonor::setAddress(Address* adr) {
	if (&_address == adr)
		return;
	_address._block_number = adr->_block_number;
	_address._city = adr->_city;
	_address._country = adr->_country;
	_address._house_number = adr->_house_number;
	_address._road_number = adr->_road_number;
}

long int BloodDonor::get_IdNumber() {
	return _IdNumber;
}
string BloodDonor::get_name() {
	return _name;
}
string BloodDonor::get_bloodGroup() {
	return _bloodGroup;
}
string BloodDonor::get_home_Phone() {
	return _home_Phone;
}
string BloodDonor::get_mobile_Phone() {
	return _mobile_Phone;
}
void BloodDonor::setAddress(int house_number, int road_number,
		int block_number, char* city, char* country) {
	_address._house_number = house_number;
	_address._road_number = road_number;
	_address._block_number = block_number;
	_address._city = city;
	_address._country = country;
}

void BloodDonor::set_IdNumber(int IdNumber) {
	_IdNumber = IdNumber;
}
void BloodDonor::set_name(char* name) {
	strcpy(_name, name);
}
void BloodDonor::set_bloodGroup(string bloodGroup) {
	if (Is_BloodBroup_Valid(bloodGroup)) {
		_bloodGroup = bloodGroup;
		return;
	}
	return;
}
void BloodDonor::set_home_Phone(string home_Phone) {
	_home_Phone = home_Phone;
}
void BloodDonor::set_mobile_Phone(string mobile_Phone) {
	_mobile_Phone = mobile_Phone;
}
bool BloodDonor::Is_BloodBroup_Valid(string blood) {
	string bloods[] = { "A+", "A-", "B+", "B-", "O+", "O-", "AB+", "AB-" };
	for (size_t i = 0; i < sizeof(bloods)/sizeof(bloods[0]); ++i) {
		if (bloods[i] == blood) {
			return true;
		}
	}
	return false;
}
void BloodDonor::InputDetails() {
	long int IdNumber;
	char name[21];
	string bloodGroup;
	string home_Phone;
	string mobile_Phone;
	cout << "Enter ID Number: ";
	cin >> IdNumber;
	set_IdNumber(IdNumber);
	cout << "Enter Name: ";
	cin >> name;
	set_name(name);
	do {
		cout << "Enter Blood Group (A+, A-, B+, B-, O+, O-, AB+, AB-): ";
		cin >> bloodGroup;
		if (!Is_BloodBroup_Valid(bloodGroup)) {
			cout << "Wrong Group" << endl;
		}
	} while (!Is_BloodBroup_Valid(bloodGroup));
	set_bloodGroup(bloodGroup);
	cout << "Enter Home Phone Number: ";
	cin >> home_Phone;
	set_home_Phone(home_Phone);
	cout << "Enter Mobile_number: ";
	cin >> mobile_Phone;
	set_mobile_Phone(mobile_Phone);
	int house_number;
	int road_number;
	int block_number;
	string city;
	string country;
	cout << "Enter House Number: ";
	cin >> house_number;
	_address._house_number = house_number;
	cout << "Road Number: ";
	cin >> road_number;
	_address._road_number = road_number;
	cout << "Block Number: ";
	cin >> block_number;
	_address._block_number = block_number;
	cout << "Enter City name: ";
	cin >> city;
	_address._city = city;
	cout << "Enter Country name: ";
	cin >> country;
	_address._country = country;
}

void BloodDonor::printDetails() {
	cout << "Donor Derails" << endl << "Id Number: " << _IdNumber << endl
			<< "Name: " << _name << endl << "Blood Group: " << _bloodGroup
			<< endl << "Home Phone: " << _home_Phone << endl << "Mobile Phon: "
			<< _mobile_Phone << endl << "Address:" << endl << "House Number: "
			<<_address._house_number << " Roiad Number: "
			<< _address._road_number << " Block Number: "
			<< _address._block_number << " City: " << _address._city
			<< " Country: " << _address._country << endl;
}

THaaaaaaaaaaaanksss a lot
THank you very very very very much
I hope for you happy life and happy days

Nobody is going to do your homework for you without pay.

Looks like someone did.

#include<iostream>
#include<string>
using namespace std;
struct	address 
{
     int housenumber;
	 int roadnumber; 
	 int blocknumber;
	 string city;
	 string country ;
};
class BloodDonor
{
private:
 long IdNumber; 
 string name;
  string	bloodGroup; 
  string	home_Phone;
 string	mobile_Phone;
address  add;

public:
BloodDonor(int Id,int hPhone,int mPhone,string name,string blood)
{
   IdNumber=Id;
   hPhone="";
   mPhone="";
   name[]="";
   blood[]="";//she said thet I have to a3.yeer the vairable
  
BloodDonor(long Id=0,string hPhone="",string mPhone="", string name="",string blood="",address pastadress);
void setID(long Id);
void setname(string name);
void setbloodGroup(string bloodGroup);
void sethome_Phone(string home_Phone);
void setmobile_Phone(string mobile_Phone);
void setadress(address a);
void setadress(int,int,int,string,string );

long getID();
string getname();
string getbloodGroup();
string gethome_Phone();
string getmobile_Phone();
address getadress();

bool BloodBroup_Valid(string blood);
void InputDetails( long,string,string ,string,string,address);
void printDetails(long,string,string ,string,string,address);
~ BloodDonor();

};


BloodDonor::BloodDonor(int Id,int hPhone,int mPhone,string name,string blood,address j)
{
}

long BloodDonor:: getID()
{
	return IdNumber;
}
string BloodDonor:: getname()
{
	return name;
}
string BloodDonor:: getbloodGroup()
{
 return bloodGroup;
}
string BloodDonor::gethome_Phone()
{
	return home_Phone;
}
string BloodDonor::getmobile_Phone()
{
	return mobile_Phone;
}
adress BloodDonor::getadress()
{
	return address;
}

void BloodDonor::setID(long Id)
{
IdNumber=Id;
}

void BloodDonor::setname(string name;int size)
{

		name=name;
}


void BloodDonor::setbloodGroup(string bloodGroup)
{
	if (bloodGroup==bloodGroup)
		return bloodGroup;
}

void BloodDonor::sethome_Phone(string home_Phone)
{
home_Phone=home_Phone;
}

void BloodDonor::setmobile_Phone(string mobile_Phone)
{
	mobile_Phone=mobile_Phone;
}

void BloodDonor::setadress(adress a)
{
	if(address ==a)
 address.housenumber=a.housenumber;
 address.roadnumber=a.roadnumber;
 address.blocknumber=a.blocknumber;
 address.city=a.city;
 address.country=a.country;
		
}

void BloodDonor::setadress(int housenumber,int roadnumber,int blocknumber,string city,string country)
{
 address.housenumber=housenumber;
 address.roadnumber=roadnumber;
 address.blocknumber=blocknumber;
 address.city=city;
 address.country=country;
}

bool BloodDonor::BloodBroup_Valid(string blood)
{
	string blood[] = { "A+", "A-", "B+", "B-", "O+", "O-", "AB+", "AB-" };
	for (int j=0;j<sizeb[blood];j++)
		if(blood[j]==blood)
			return true;
		else
			return false;
}

void BloodDonor::InputDetails( long IdNumber,string name,string bloodGroup ,string home_Phone,string mobile_Phone,adress b)
{
		
	
	cout << "Enter ID Number: ";
	cin >> IdNumber;
   setID(IdNumber);
	cout << "Enter Name: ";
	cin >> name;

	do {		
		cout << "Enter Blood Group (A+, A-, B+, B-, O+, O-, AB+, AB-): ";
		cin >> bloodGroup;
		if (!Is_BloodBroup_Valid(bloodGroup)) 
		{		
			cout << "Wrong Group" << endl;
		}	
}
	while (!Is_BloodBroup_Valid(bloodGroup));

    setbloodGroup(bloodGroup);

	cout << "Enter Home Phone Number: ";

	cin >> home_Phone;

	sethome_Phone(home_Phone);	

	cout << "Enter Mobile number: ";
	cin >> mobile_Phone;	
	setmobile_Phone(mobile_Phone);	
	int house_number;
	int road_number;
	int block_number;
	string city;
	string country;	
	cout << "Enter House Number: ";
	cin >> house_number;
    address.housenumber = house_number;
	cout << "Road Number: ";	
	cin >> road_number;
	address.roadnumber= road_number;
	cout << "Block Number: ";
	cin >> block_number;
    address.blocknumber = block_number;
	cout << "Enter City name: ";
	cin >> city;
	address.city = city;	
	cout << "Enter Country name: ";	
	cin >> country;
	address.country = country;
}
void BloodDonor::printDetails(long IdNumber,string name,
				  string bloodGroup ,string home_Phone,
				  string mobile_Phone,adress b)
{
	cout << "Donor Derails" << endl;
    cout<< "Id Number: " << IdNumber << endl;
	cout<< "Name: " << name << endl;
	cout<< "Blood Group: " <<bloodGroup<< endl;
	cout<< "Home Phone: " << home_Phone << endl;
	cout<< "Mobile Phon: "<< mobile_Phone << endl;
	cout<< "Address:" << endl;
	cout<< "House Number: "	<<address.house_number <<endl;
	cout<< " Roiad Number: "<< address.road_number<<endl;
	cout<< " Block Number: "<< address.block_number <<endl;
	cout<< " City: " << address.city<<endl;
	cout<< " Country: " << address.country << endl;
}
BloodDonor::~ BloodDonor()
{
cout<<"class is terminated;
}

int main() 

{
	Address adr(1,1,1,"Manama","Bahrain");
	BloodDonor donor1(56789, "Ahmed", "B+", "17123456", "39999999", adr  );
	donor1.setmobile_Phone("39888888");
	cout << donor1.getmobile_Phone() << endl;
	donor1.printDetails();
	BloodDonor donor2;
	donor2.InputDetails();
	donor2.printDetails();
	return 0;
}

This is my answer there are 70 error
:(
:(
can any body tell me how could I solve them????

please I need help
today after 3 hours I have to submit this assignment

#include<iostream>
#include<string>
using namespace std;
struct address {
	int housenumber;
	int roadnumber;
	int blocknumber;
	string city;
	string country;
	address(int _housenumber = 0, int _roadnumber = 0, int _blocknumber = 0, string _city = "", string _country = "") {
		housenumber = _housenumber;
		roadnumber = _roadnumber;
		blocknumber = _blocknumber;
		city = _city;
		country = _country;
	}
};
class BloodDonor {
private:
	long IdNumber;
	string name;
	string bloodGroup;
	string home_Phone;
	string mobile_Phone;
	address add;

public:
	BloodDonor(int, string, string, string, string);
	BloodDonor(long Id=0, string hPhone="", string mPhone="", string name="", string blood="", address x = 0);
	void setID(long Id);
	void setname(string name);
	void setbloodGroup(string bloodGroup);
	void sethome_Phone(string home_Phone);
	void setmobile_Phone(string mobile_Phone);
	void setadress(address a);
	void setadress(int, int, int, string, string);

	long getID();
	string getname();
	string getbloodGroup();
	string gethome_Phone();
	string getmobile_Phone();
	address& getadress();

	bool BloodBroup_Valid(string blood);
	void InputDetails();
	void printDetails();
	~ BloodDonor();

};
BloodDonor::BloodDonor(int _Id, string _hPhone, string _mPhone, string _name, string _blood) {
	IdNumber = _Id;
	name = _name;
	bloodGroup = _blood;
	home_Phone = _hPhone;
	mobile_Phone = _mPhone;
}

BloodDonor::BloodDonor(long _Id, string _hPhone, string _mPhone, string _name, string _blood, address pastadress) {
	IdNumber = _Id;
	name = _name;
	bloodGroup = _blood;
	home_Phone = _hPhone;
	mobile_Phone = _mPhone;
	add = pastadress;

}

long BloodDonor::getID() {
	return IdNumber;
}
string BloodDonor::getname() {
	return name;
}
string BloodDonor::getbloodGroup() {
	return bloodGroup;
}
string BloodDonor::gethome_Phone() {
	return home_Phone;
}
string BloodDonor::getmobile_Phone() {
	return mobile_Phone;
}
address& BloodDonor::getadress() {
	return add;
}

void BloodDonor::setID(long Id) {
	IdNumber=Id;
}

void BloodDonor::setname(string name) {
	name=name;
}

void BloodDonor::setbloodGroup(string _bloodGroup) {
	if (bloodGroup != _bloodGroup)
		bloodGroup = _bloodGroup;
}

void BloodDonor::sethome_Phone(string home_Phone) {
	home_Phone=home_Phone;
}

void BloodDonor::setmobile_Phone(string mobile_Phone) {
	mobile_Phone=mobile_Phone;
}

void BloodDonor::setadress(address a) {
	add.housenumber=a.housenumber;
	add.roadnumber=a.roadnumber;
	add.blocknumber=a.blocknumber;
	add.city=a.city;
	add.country=a.country;

}

void BloodDonor::setadress(int housenumber, int roadnumber, int blocknumber, string city, string country) {
	add.housenumber=housenumber;
	add.roadnumber=roadnumber;
	add.blocknumber=blocknumber;
	add.city=city;
	add.country=country;
}

bool BloodDonor::BloodBroup_Valid(string blood) {
	string bloods[] = { "A+", "A-", "B+", "B-", "O+", "O-", "AB+", "AB-" };
	for (size_t j=0; j< sizeof(bloods)/sizeof(bloods[0]); j++)
		if (bloods[j]==blood)
			return true;

	return false;
}

void BloodDonor::InputDetails() {
	cout << "Enter ID Number: ";
	cin >> IdNumber;
	setID(IdNumber);
	cout << "Enter Name: ";
	cin >> name;

	do {
		cout << "Enter Blood Group (A+, A-, B+, B-, O+, O-, AB+, AB-): ";
		cin >> bloodGroup;
		if (!BloodBroup_Valid(bloodGroup)) {
			cout << "Wrong Group" << endl;
		}
	} while (!BloodBroup_Valid(bloodGroup));
	setbloodGroup(bloodGroup);

	cout << "Enter Home Phone Number: ";

	cin >> home_Phone;

	sethome_Phone(home_Phone);

	cout << "Enter Mobile number: ";
	cin >> mobile_Phone;
	setmobile_Phone(mobile_Phone);

	cout << "Enter House Number: ";
	cin >> add.housenumber;
	cout << "Road Number: ";
	cin >> add.roadnumber;
	cout << "Block Number: ";
	cin >> add.blocknumber;
	cout << "Enter City name: ";
	cin >> add.city;
	cout << "Enter Country name: ";
	cin >> add.country;

}
void BloodDonor::printDetails() {
	cout << "Donor Derails" << endl;
	cout<< "Id Number: " << IdNumber << endl;
	cout<< "Name: " << name << endl;
	cout<< "Blood Group: " <<bloodGroup<< endl;
	cout<< "Home Phone: " << home_Phone << endl;
	cout<< "Mobile Phon: "<< mobile_Phone << endl;
	cout<< "Address:" << endl;
	cout<< "House Number: " <<add.housenumber <<endl;
	cout<< "Roiad Number: "<< add.roadnumber<<endl;
	cout<< "Block Number: "<< add.blocknumber <<endl;
	cout<< "City: " << add.city<<endl;
	cout<< "Country: " << add.country << endl;
}
BloodDonor::~BloodDonor() {
	cout<<"class is terminated";
}

int main() {
	BloodDonor donor1(56789, "Ahmed", "B+", "17123456", "39999999", address(1, 1, 1, "Manama", "Bahrain"));
	donor1.setmobile_Phone("39888888");
	cout << donor1.getmobile_Phone() << endl;
	donor1.printDetails();
	BloodDonor donor2;
	donor2.InputDetails();
	donor2.printDetails();
	return 0;
}

your code was sooooo wrong, but i fix it...

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.