- تاريخ التسجيل
- 14 سبتمبر 2012
- المشاركات
- 2,834
- المجموعة
- ذكر
- الدفعة الدراسية
- 2012
- الكلية
- كلية تقنية المعلومات
- التخصص
- CS - متقاعد
مفي مشكلة ...عندي سؤال ممكن أطرشه لك ..؟ طبعا مع محاولتي فقط للتأكد منه![]()
NP
مفي مشكلة ...عندي سؤال ممكن أطرشه لك ..؟ طبعا مع محاولتي فقط للتأكد منه![]()



Assignment#5
Create a class called BloodDonor that maintains information about blood donors in a blood bank having the following data members:
[*=left]IdNumber, // long int
[*=left]name, //Name of donor
[*=left]bloodGroup//String
[*=left]home_Phone//String
[*=left]mobile_Phone//String
[*=left]address // struct Address that holds int house number, int road number, int block
number, string city, and string countryIt will also have the following member functions:
[*=left]Constructor function with default values IdNumber = 0, name = "", bloodGroup = "",
home_Phone="", mobile_Phone="", address={0,0,0,"",""}.
[*=left]An overloaded constructor that takes the same parameters of the constructor in except Address for the address
[*=left]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.
[*=left]Is_BloodGroup_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-.
[*=left]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.
[*=left]printDetails // Print the details (IdNumber,name, bloodGroup, home phone, mobile phone, and address) of the donor8. Destructor function.
PART A
Write the class BloodDonor and the code of the member functions.
PART B
Write a main function which includes the following:
[*=left]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"}-
[*=left]Write a statement to change the mobile phone to "39888888".
[*=left]Write a statement to print the mobile phone.
[*=left]Write a statement to print the details of donor.
[*=left]Create another object named donor2 of type BloodDonor.
[*=left]Ask the user to enter the details of the donor2 by calling InputDetails function
[*=left]Print the details of donor2.
يطلع 7 ايرور
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.


//Noise-X
#include<iostream>
#include<string>
using namespace std;
struct Address{
int houseNo;
int roadNo;
int blockNo;
string city;
string country;
};
class BloodDonor
{
private:
long IdNumber;
string name;
string bloodGroup;
string home_Phone;
string mobile_Phone;
Address address;
public:
BloodDonor(long =0, string =" ",string =" ",string =" ",string =" ",int =0,int =0,int =0,string =" ",string =" ");
~BloodDonor();
BloodDonor(long id, string n,string bg,string h,string m);
void setIdNumber(long);
void setname(string);
void setbloodGroup(string);
void sethome_Phone(string);
void setmobile_Phone(string);
void setaddress(int,int,int,string,string,Address);
long getIDNumber();
string getname();
string getbloodGroup();
string gethome_Phone();
string getmobile_Phone();
void getaddress(int&,int&,int&,string&,string&,Address);
bool Is_BloodBroup_Valid(string E);
void InputDetails();
void printDetails();
};
BloodDonor::BloodDonor (long id, string n,string bg,string hp,string mp,int h,int r,int b,string ci,string co)
{
setIdNumber(id);
setname(n);
setbloodGroup(bg);
sethome_Phone(hp);
setmobile_Phone(mp);
setaddress(h,r,b,ci,co,address);
}
BloodDonor::BloodDonor(long id, string n,string bg,string hp,string mp)
{
setIdNumber(id);
setname(n);
setbloodGroup(bg);
sethome_Phone(hp);
setmobile_Phone(mp);
}
void BloodDonor::setIdNumber(long id)
{
IdNumber=id;
}
void BloodDonor::setname(string n)
{
name=n;
}
void BloodDonor::setbloodGroup(string bg)
{
bloodGroup=bg;
}
void BloodDonor::sethome_Phone(string hp)
{
home_Phone=hp;
}
void BloodDonor::setmobile_Phone(string mp)
{
mobile_Phone=mp;
}
void BloodDonor::setaddress(int h,int r,int b,string ci,string co,Address address)
{
address.houseNo=h;
address.roadNo=r;
address.blockNo=b;
address.city=ci;
address.country=co;
}
long BloodDonor::getIDNumber()
{
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;
}
void BloodDonor::getaddress(int &h,int &r,int &b,string &ci,string &co,Address address)
{
h=address.houseNo;
r=address.roadNo;
b=address.blockNo;
ci=address.city;
co=address.country;
}
bool BloodDonor::Is_BloodBroup_Valid(string BG)
{
if(BG=="A+"||BG== "A-"||BG== "B+"||BG== "B-"||BG== "0+"||BG== "0-"||BG=="AB+"||BG=="AB")
return true;
else
return false;
}
void BloodDonor::InputDetails()
{
cout<<"enter your IdNumber, name, blood group, home phone, mobile phone, house number,block number, city and your country"<<endl;
cin>>IdNumber>>name>>bloodGroup>>home_Phone>>mobile_Phone;
cin>>address.houseNo>>address.blockNo>>address.roadNo>>address.city>>address.country;
}
void BloodDonor::printDetails()
{
cout<<"Id number="<<IdNumber<<"\nname="<<name<<"\nblood group="<<bloodGroup<<"\nhome phone="<<home_Phone<<"\nmobile phone="<<mobile_Phone;
cout<<"\naddress="<<address.houseNo<<address.blockNo<<address.roadNo<<address.city<<address.country<<endl<<endl;
}
BloodDonor::~BloodDonor()
{cout<<"Clear Done"<<endl;}
int main()
{
BloodDonor donor1 (56789,"Ahmed","B+","17123456","39999999",1,1,1,"manama","Bahrain");
donor1.setmobile_Phone("39688888");
cout<<donor1.getmobile_Phone();
donor1.printDetails();
long id;
string n,bg,hp,mp,city,country;
int hn,rn,bn;
cout<<"Enter your id:";
cin>>id;
cout<<"Enter your name:";
cin>>n;
cout<<"Enter your boodgoup:";
cin>>bg;
cout<<"Enter your home phone:";
cin>>hp;
cout<<"Enter your mobile phone:";
cin>>mp;
cout<<"Enter your house number:";
cin>>hn;
cout<<"Enter your road number:";
cin>>rn;
cout<<"Enter your block number:";
cin>>bn;
cout<<"Enter your city name:";
cin>>city;
cout<<"Enter your country name:";
cin>>country;
BloodDonor donor2(id,n,bg,hp,mp,hn,rn,bn,city,country);
donor2.printDetails();
return 0;
}
اعضاء الملتقى الكرام
رجاءا اي برنامج ينعرض في المنتدى لا تسوون له كوبي بيست
انتون بهذي الطريقة ماتستفيدون شي بالعكس يصير فيه تطابق في الاسايمينتات والكل يحصل صفر
تخربون ع نفسكم وع اللي رفع الحل
وبعدين عاد ماتوصل ان يطرش البرنامج مع توقيع العضو اللي سواه ,, يعني تخبر الدكتورة اشكرا انا مسوي كوبي بيست وماقريت الحل
.. . هذا السؤال بدون أخطاء بس ما أدري صح أو لا " مثل ما السؤال طالب " ..
نخلص الريض ونرجع ليكم ..

انزين مايصير نخلي ال void set كلهم في فنكشن وحدة !! ؟؟ :mellow:
اني كنت فاهمة السؤال طول الوقت هيك![]()
اعضاء الملتقى الكرام
رجاءا اي برنامج ينعرض في المنتدى لا تسوون له كوبي بيست
انتون بهذي الطريقة ماتستفيدون شي بالعكس يصير فيه تطابق في الاسايمينتات والكل يحصل صفر
تخربون ع نفسكم وع اللي رفع الحل
وبعدين عاد ماتوصل ان يطرش البرنامج مع توقيع العضو اللي سواه ,, يعني تخبر الدكتورة اشكرا انا مسوي كوبي بيست وماقريت الحل
السلام عليكم
لو سمحتوواا ممكن أحد يسااعدني
The first part
(1) Define and Implement a class named BankAccount. The data members of the class BankAccount are: AccountNumber (long), Name (string), and Balance (float). In addition, the class BankAccount contains the following member functions:
- Set functions for each of the data member.
- Get functions for each of the data member.
- DisplayAccountDetails that prints (on the screen) all the information about the Account.
- A Constructor with default values parameters where the default values are 999 for AccountNumber, "" for Name, and 0.0 for Balance.
- A destructor function that displays the message "Object deleted".
(2) Write a main function to test your class, as follow:
a. Write one statement to define an object named myAccount from the class BankAccount with values of 9876543, "Customer", 2000 for the data members AccountNumber, Name, and Balance respectively.
b. Write statements that will withdraw an amount of 1000 from the account myAccount then prints the following messages:
Opening Balance:????
Amount of Withdrarwal: 1000.
Remaining Balance:????
Where??? are the values of the previous balance (before the withdrawal) and the new balance (after the withdrawal) respectively. Use values from the object myAccount. Do not put values for these numbers yourself.
Part II
(1) Complete the class defined in the previous exercise to include the following functions:
• Withdraw function which is used to withdraw a certain amount X from the Account. It should check that the balance in the account is at least equal to X (ie X or more) before it allows the withdrawal and reduce the Balance by X.
• Deposit which is used to Deposit a certain amount Y into the Account. It should of course increase the Balance by Y.
• IsAccountEmpty which returns true if the Balance is less than or equal to zero. Otherwise it returns false.
(2) Write a main function to test your class as follow:
- Write one statement to define an array named AccountList with size 300 that contains objects of class BankAccount.
- Write statements to print on the screen all the empty Accounts in AccountList (that have a balance of zero or less). Assume that the list length is 100.
(1) Define and Implement a class named BankAccount. The data members of the class BankAccount are: AccountNumber (long), Name (string), and Balance (float). In addition, the class BankAccount contains the following member functions:.
- Set functions for each of the data member.
- Get functions for each of the data member.
- DisplayAccountDetails that prints (on the screen) all the information about the Account.
- A Constructor with default values parameters where the default values are 999 for AccountNumber, "" for Name, and 0.0 for Balance.
- A destructor function that displays the message “Object deleted”.
(2) Write a main function to test your class, as follow:
a. Write one statement to define an object named myAccount from the class BankAccount with values of 9876543, "Customer”, 2000 for the data members AccountNumber, Name, and Balance respectively.
b. Write statements that will withdraw an amount of 1000 from the account myAccount then prints the following messages:
Opening Balance: ????
Amount of Withdrarwal: 1000.
Remaining Balance: ????
Where ??? are the values of the previous balance (before the withdrawal) and the new balance (after the withdrawal) respectively. Use values from the object myAccount. Do not put values for these numbers yourself
سلام عليكم .. ممكن مساعدتي في بارت 2 (B) ؟ مشيره في آخر السؤال؟
انزين مايصير نخلي ال void set كلهم في فنكشن وحدة !! ؟؟ :mellow:
اني كنت فاهمة السؤال طول الوقت هيك![]()


//Noise-X
#include<iostream>
#include<string>
using namespace std;
struct Address{
int houseNo;
int roadNo;
int blockNo;
string city;
string country;
};
class BloodDonor
{
private:
long int IdNumber;
string name;
string bloodGroup;
string home_Phone;
string mobile_Phone;
Address address;
public:
BloodDonor(long =0, string =" ",string =" ",string =" ",string =" ",int =0,int =0,int =0,string =" ",string =" ");
~BloodDonor();
BloodDonor(long id, string n,string bg,string h,string m);
void set(long,string,string,string,string);
void setaddress(int,int,int,string,string,Address);
void get (long&,string&,string&,string&,string&);
void getaddress(int&,int&,int&,string&,string&,Address);
void setBloodgroup ();
bool Is_BloodBroup_Valid(string E);
void InputDetails();
void printDetails();
};
BloodDonor::BloodDonor (long id, string n,string bg,string hp,string mp,int h,int r,int b,string ci,string co)
{
IdNumber=id;
name=n;
bloodGroup=bg;
home_Phone=hp;
mobile_Phone=mp;
address.houseNo=h;
address.roadNo=r;
address.blockNo=b;
address.city=ci;
address.country=co;
}
BloodDonor::BloodDonor(long int id, string n,string bg,string hp,string mp)
{
id=IdNumber;
n=name;
bg=bloodGroup;
hp=home_Phone;
mp=mobile_Phone;
}
void BloodDonor::set (long int id, string n,string bg,string h,string m)
{
IdNumber=id;
name=n;
bloodGroup=bg;
home_Phone=h;
mobile_Phone=m;
}
void BloodDonor::get (long int &id, string &n,string &bg,string &h,string &m)
{
id=IdNumber;
n=name;
bg=bloodGroup;
h=home_Phone;
m=mobile_Phone;
}
void BloodDonor::setaddress(int h,int r,int b,string ci,string co,Address address)
{
address.houseNo=h;
address.roadNo=r;
address.blockNo=b;
address.city=ci;
address.country=co;
}
void BloodDonor::getaddress(int &h,int &r,int &b,string &ci,string &co,Address address)
{
h=address.houseNo;
r=address.roadNo;
b=address.blockNo;
ci=address.city;
co=address.country;
}
void BloodDonor::setBloodgroup ()
{
int c=1;
string BG;
do {
cin>>BG;
if (Is_BloodBroup_Valid(BG))
bloodGroup=BG;
}while(c>0);
}
bool BloodDonor::Is_BloodBroup_Valid(string BG)
{
if(BG=="A+"||BG== "A-"||BG== "B+"||BG== "B-"||BG== "O+"||BG== "O-"||BG=="AB+"||BG=="AB")
return true;
else
{
cout<<"BloodBroup_Valid\n";
return false;
}
}
void BloodDonor::InputDetails()
{
cout<<"Enter your id: ";
cin>>IdNumber;
cout<<"Enter your name: ";
cin>>name;
cout<<"Enter your boodgoup: ";
setBloodgroup();
cout<<"Enter your home phone: ";
cin>>home_Phone;
cout<<"Enter your mobile phone: ";
cin>>mobile_Phone;
cout<<"Enter your house number: ";
cin>>address.houseNo;
cout<<"Enter your road number: ";
cin>>address.roadNo;
cout<<"Enter your block number: ";
cin>>address.blockNo;
cout<<"Enter your city name: ";
cin>>address.city;
cout<<"Enter your country name: ";
cin>>address.country;
cout<<endl;
}
void BloodDonor::printDetails()
{
cout<<"Enter your id: "<<IdNumber<<endl;
cout<<"Enter your name: "<<name<<endl;
cout<<"Enter your boodgoup: "<<bloodGroup<<endl;
cout<<"Enter your home phone: "<<home_Phone<<endl;
cout<<"Enter your mobile phone: "<<mobile_Phone<<endl;
cout<<"Enter your house number: "<<address.houseNo<<endl;
cout<<"Enter your road number: "<<address.roadNo<<endl;
cout<<"Enter your block number: "<<address.blockNo<<endl;
cout<<"Enter your city name: "<<address.city<<endl;
cout<<"Enter your country name: "<<address.country<<endl<<endl;
}
BloodDonor::~BloodDonor()
{cout<<"Clear Done"<<endl;}
int main()
{
long id;
string n,bg,hp,mp,city,country;
BloodDonor donor1 (56789,"Ahmed","B+","17123456","39999999",1,1,1,"manama","Bahrain");
donor1.get(id,n,bg,hp,mp);
donor1.set(id,n,bg,hp,"39688888");
donor1.get(id,n,bg,hp,mp);
cout<<"Mobile phone : "<<mp<<endl<<endl;
donor1.printDetails();
BloodDonor donor2;
donor2.InputDetails();
donor2.printDetails();
return 0;
}

+ ممنوع الاجابات الجاهزة الكاملة
