شيئية OOP
Open in Telegram
عمي رحمة لوالديك ولعشيرتك وللعزاز وللعراق وللشرق الأوسط، لا تكعد تحفظ الأكواد الكود فهم فهم فهم مو حفظ و السلام
Show more234
Subscribers
No data24 hours
-47 days
-930 days
Posts Archive
234
EX2 :
A health care application, that specializes in tracking the weight of persons, has a class called personWeight with three variables (name, gender, and weight). Implement a method to give an appropriate message according to the following conditions:
1- “name you are overweight” if the person is male and his weight more than 80 kg else “you
are fit”.
2- “name you are overweight” if the person is female and his weight more than 60 kg else
“you are fit”.
Note: Instantiate an object called person of type personWeight. Use constructor to initialize the variables.
#include <iostream>
using namespace std;
class personweight {
protected :
string name;
float weight;
string gender;
public :
personweight ( string n, float w, string g ) {
name = n;
weight = w;
gender = g;
}
void printStatus() {
if ( (weight > 80 && gender == "male") || (weight > 60 && gender == "female") ) {
cout << name << " you are overweight" << endl;
} else {
cout << name << " you are fit" << endl;
}
}
};
int main() {
personweight person1 = {"am_kean", 56, "female"};
personweight person2 = {"abo_kean", 89, "male"};
person1.printStatus();
person2.printStatus();
return 0;
}234
Ex1 :
Design a health care application to check the blood pressure of a patients. The application has a struct called patientPressure with a member variable (name, age, gender). Implement a method to issue the following message:
1- “name your blood pressure is high” if the systolic blood pressure is over 120mm Hg.
2- “name your blood pressure is normal” if the systolic blood pressure is between (100-120) mm Hg.
3- “name your blood pressure is low” if the systolic blood pressure is less 100 mm Hg.
Note: Instantiate an object called patient of type patientPressure.
#include <iostream>
using namespace std;
struct patientPressure {
string name;
int age;
string gender;
void issue(int pressure) {
if(pressure > 120) {
cout<< name << " your blood pressure is high " << endl;
}
if(pressure >= 100 && pressure <= 120) {
cout<< name << " your blood pressure is normal " << endl;
}
if(pressure < 100) {
cout<< name << " your blood pressure is low " << endl;
}
}
};
int main()
{
patientPressure patient1 = {"salam", 34, "male"};
patient1.issue(110);
return 0;
}234
Repost from تجمع سجاجة البصرة
هذا الكوز بصيغة Class الي طبقها دكتور ضياء خلال المحاضرة :
#include <iostream>
using namespace std;
class personweight {
public :
string name;
float weight;
string gender;
void printStatus() {
if ( (weight > 80 && gender == "male") || (weight > 65 && gender == "female") ) {
cout << name << " you are overweight" << endl;
} else {
cout << name << " you are fit" << endl;
}
}
};
int main() {
personweight person1 = {"am_kean", 56, "female"};
personweight person2 = {"abo_kean", 89, "male"};
person1.printStatus();
person2.printStatus();
return 0;
}234
Repost from تجمع سجاجة البصرة
هذا رابط ل63 سؤال
بداخله اسئلة عن البوينتر/رفرنس/ستركتر
https://t.me/no_zero_any_more/713
هنا بعض الأكواد والافكار وان كانت بسيطة حاول تصعبها مثلا سويها كلاس او طورها وهيج أمور
https://t.me/no_zero_any_more/1120
وهذا الملف👆
234
Repost from تجمع سجاجة البصرة
هذا ملف للهياكل يتضمن افكار
مو كل الافكار اخذناهن
اقرأ الكود و فقط الي ضمن مادتنا طبقه
234
Repost from تجمع سجاجة البصرة
حل السؤال بالصيغة الصحيحة :
#include <iostream>
using namespace std;
class subjects
{
protected:
string name;
int oop;
int math;
int english;
public:
subjects(string name,int oop ,int math,int english){
this->name=name;
this->oop=oop;
this->math=math;
this->english=english;
}
int sum()
{
return oop + math + english;
}
};
class studentavrage{
public:
void avrage(double s){
cout << "Average: " <<s/3 << endl;
}
};
class student:public subjects,public studentavrage{
public:
student(string name,int oop,int math,int english):subjects(name,oop,math,english){}
};
int main() {
student s1("yas",90,77,56);
double a= s1.sum();
s1.avrage(a);
return 0;
}234
Repost from تجمع سجاجة البصرة
Creat a class with name students this class sould inherit the students name and three data members (opp,math,English) from a class called subject which has a method to calculate the sum of the students degrees further the derivied class can acess a method student to calculate the students average in class called student average.
234
Repost from تجمع سجاجة البصرة
#include <iostream>
using namespace std;
class bank {
public :
string AccountHolder;
int AccountNumber;
double balance;
bank ( string AccountHolder, int AccountNumber, double balance) {
this->AccountHolder = AccountHolder;
this->AccountNumber = AccountNumber;
this->balance = balance;
}
void deposit (double amount) {
balance += amount;
}
void withDrawal(double amount);
friend void display (bank bank);
};
void bank::withDrawal(double amount) {
if (balance > amount ){
balance -= amount;
}
else {
cout << "balance < amount "<<endl;
}
}
void display (bank bank) {
cout << "AccountHolder : " << bank.AccountHolder << ", AccountNumber : " << bank.AccountNumber << ", balance : " << bank.balance << endl;
};
int main()
{
bank s1 = {"mogo", 78904, 1090};
s1.deposit(24.5);
s1.withDrawal(9.5);
display(s1);
return 0;
}234
Repost from تجمع سجاجة البصرة
اسم ملف الهدر بكيفك
انا سميته main
دكتور ضياء سماه هدر
و عندي هدر ثاني مسميه kjh
هو المهم اسم.h
234
Repost from تجمع سجاجة البصرة
افهم هذا الموضوع و فكرة الكود
كلش مهم باجر ناخذ امور مرتبطة بيه و مهمة
افهم هذا حتى ما تواجه مشاكل بالقادم و يكون ابسط
بالتوفيق للجميع
234
Repost from تجمع سجاجة البصرة
#ifndef main.h // اسم الملف.h
#define mainh // اسم الملف h
#include <string> // حسب الحاجة
using namespace std; // حسب الحاجة + نحتاجه هنا
class bank {
public :
string AccountHolder;
int AccountNumber;
double balance;
void deposit (double amount) {
balance += amount;
}
void withDrawal(double amount) {
if (balance > amount ){
balance -= amount;
}
else {
cout << "balance < amount "<<endl;
}
}
void display (){
cout << "AccountHolder : " << AccountHolder << ", AccountNumber : " << AccountNumber << ", balance : " << balance << endl;
}
};
#endif // main
234
Repost from تجمع سجاجة البصرة
#include <iostream>
#include "main.h" // اسم الملف .h
//using namespace std; // حسب الحاجة
int main()
{
bank s1 = {"am0m", 3456, 360.5};
//s1.deposit(50.9); // هنا لازم نشغل وحده فقط اما هذا
s1.withDrawal(33.6); // او هذا
s1.display();
return 0;
}
