شيئية OOP
281 subscribers
53 photos
10 files
12 links
عمي رحمة لوالديك ولعشيرتك وللعزاز وللعراق وللشرق الأوسط، لا تكعد تحفظ الأكواد
الكود فهم فهم فهم مو حفظ
و السلام
Download Telegram
الثالثة هنا الشغل بيها
اسمها display و تعرض المعلومات المحدثة
يعني بعد السحب و بعد الإيداع
مثل ما مبين بداخلها فقط cout
1
الى هنا يخلص ال class
نبدأ بالmain
هنا كتب اسم الكلاس و اسم الشخص
انا سميته s1
انت بكيفك شتسميه سميه ماكو فرق
و مثل ما موضحه ندخل بيه
اسم الحساب
رقم الحساب
الفلوس الي بالحساب
و نخليها بداخل اقواس { };
ليش نستخدم هاي الطريقة حتى الكود يصير ابسط و اسهل اكو طرق بالملزمة تطول السالفة كل حقل له سطر بحده ف يصير طويل الكود و مزعج

ورا ما ندخل القيم
نسوي استدعاءات للفنكشن
1-
deposit
نكتب لها رقم معين من يمك هو كمية الايداع انت شكد تريد تضيف للحساب بكيفك .
و نكتب اسم عنصر الكلاس مالت الmain
s1.deposit(50.9);
لازم نحط نقطة بينهن حتى يتم الاستدعاء بشكل صحيح .
2-
withDrawal
هنا نفس الحجي للي قبلها

3-
display
هنا فقط تعرض معلومات بعد الإضافة او بعد النقصان و هاي تبقى دائماً شغاله


هنا الكود تشغل بيه فنكشن وحدة فقط من فنكشنات deposit او withDrawal
حتى الي يظهر علشاشة يصير صحيح .
1
نبلش شلون تسويه ملف هدر ( .h )
خل نتفق على شغلة
هدر هو نوع الملف مو اسم ثابت
يعني انا مسميه mohd.h
هذا يعتبر ملف هدر ايضاً ماكو مشكلة

هذا الملف نسويه بداخل ملف البروجكت نفسه مو بحده
يعني اضافة ملف من اعلى البرنامج و بداخل نفس ملف البروجكت ركز على هاي
كون يصير هيج👇
1
الهدر شلون نسويه
هذا شيء حلو يصير
نروح لمكان ملف هدر .h
و تكتب
#ifndef اسم.h
انا سميته main
ف يصير
#ifndef main.h

ورا ما تكتب هذا تنطيه enter كبل يطلعلك

#endif

انت تكتب الكود بينهن

يعني

#ifndef main.h

// الكود
#endif

هيج هسه شني الاضافات الي عدنا

بعد ( #ifndef main.h ) نكتب
#define main.h // اسم الهدر .h

و نكتب هذني و نعرفهن حسب الحاجة اي لو لا .
و هنا نحتاجهن حتى ما يخبط الكود
و std لان عدنا cout و تحتاجه
#include <string>
using namespace std;

ف الترتيب يصير

#ifndef main.h // اسم الهدر .h
#define mainh // اسم الهدر .h

#include <string> // حسب الحاجة
using namespace std; // حسب الحاجة

// الكود هنا

#endif
1
الكود بعد ما يكون بشكل هدر👇
1
#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;
}
1
#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
2
افهم هذا الموضوع و فكرة الكود
كلش مهم باجر ناخذ امور مرتبطة بيه و مهمة
افهم هذا حتى ما تواجه مشاكل بالقادم و يكون ابسط
بالتوفيق للجميع
1
#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;
}
1
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.
2
تجمع بؤساء الهندسة²⁴⁻²³
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…
حل السؤال بالصيغة الصحيحة :

#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;
}
1👍1
تجمع بؤساء الهندسة²⁴⁻²³
OOP Examples.pdf
هذا ملف للهياكل يتضمن افكار

مو كل الافكار اخذناهن
اقرأ الكود و فقط الي ضمن مادتنا طبقه
1