شيئية OOP
282 subscribers
53 photos
10 files
12 links
عمي رحمة لوالديك ولعشيرتك وللعزاز وللعراق وللشرق الأوسط، لا تكعد تحفظ الأكواد
الكود فهم فهم فهم مو حفظ
و السلام
Download Telegram
👍2
هاي الحفظيات
كذلك بمرور الوقت راح ننزل الباقي بشكل ملف كامل ان شاء الله
2
CoE 123 Object oriented programming.pdf
2.4 MB
الشرحيات بتأشير الدكتور على الداتا شو
مع تأشيرات من عندي اتوقعها تجي كفراغات او صح وخطأ ليس إلا
10🔥1💊1
عود صدك تردون مرشحات ؟
👍35👎4😢4💯31❤‍🔥1
شيئية OOP
مثال عن polymorphism : #include <iostream> using namespace std; class Shape { public: virtual double area() = 0; }; class Circle : public Shape { private: double radius; public: Circle(double r) { radius = r; } double area() { return…
هذا السؤال

بس يكلك سويه بالابستراكشن
هيج يصير
#include <iostream>
using namespace std;

class Shape {
public:
virtual void area() = 0;
};


class Circle : public Shape {
private:
double radius;

public:
Circle(double r): radius(r){}

void area() {
cout << "Circle area: "<< 3.14 * radius * radius << endl;
}
};


class Rectangle : public Shape {
private:
double length;
double width;

public:
Rectangle(double l, double w): length(l), width(w) {}

void area() {
cout << "Rectangle area: " << length * width << endl;
}
};


int main() {
Circle circle(5);
Rectangle rectangle(4, 6);

circle.area();
rectangle.area();

return 0;
}

اول يكلك سويه بمفهوم توقع المشاكل ( catch , try , throw )
ايضا سهل
جربوه بطريقكم
4🔥1
هذني هن الافكار الممكنة
عليك فهم الكود
لان ما راح يجي نصاً
ممكن يعدل عليه شي بسيط
و اضافات ما تأثر
مثلا يكلك المتغيرات نفس الاسم بالكونستركتر
هنا تستخدم
this->
و موجود مثال بالقناة ( سؤال رقم 12 )

او يكلك سوي سكوب ( : : )
وهيج سوالف
👍8👏1
و اول سؤال حفظيات بله
عليه عشر درجات
أقروا الملف و فكروا بنفس نمط فراغات المد
كذلك ممكن يكرر بعض الفراغات لان الاغلبية ما مجاوبة
👍10
شيئية OOP
الحل : #include<iostream> using namespace std; class carengine { public: virtual void check()=0; }; class Water : public carengine { private: int watertemperature; public: Water(int w = 0):watertemperature(w){} void check() { …
الكوز
هو وحش الهياكل لان طبق بيه مواضيعنا كلها تقريباً ( بدون الاوفرلودنك طبعاً )
فعملياً هذا الي يطبقه و يفهمه
وضعه كلش حلو باجر
👍5
اسئلة فاينل الهياكل OOP بتاريخ :
2024/5/22
💔14🤓4😨42
شيئية OOP
Photo
Q1/
1-Instance
2-Blueprint
3-Alias
4-Nullptr
5-Overloading
6-early binding
7-Abstraction
8-abstract data type
9-encapsulation
10-problem
2👍2💔2
شيئية OOP
Photo
Q2/

A/
#include<iostream>
using namespace std;
class Rectangle
{
protected:
double lenght,width;
public:
Rectangle(double l,double w):lenght(l),width(w){}
};

class cuboid : public Rectangle
{
double height;
public:
cuboid(double l,double w,double h):Rectangle(l,w),height(h){}
void volume()
{
cout<<"area of cuboid : "<<lenght*width*height<<endl;
}
};

int main()
{
cuboid r(2.2,10.5,5.2);
r.volume();
}


B/
#include<iostream>
using namespace std;

class Cars {
private:
string brandN;
int maxspeed, fuelC, safetyR;
public:
Cars(string b,int m,int f,int s):brandN(b),maxspeed(m),fuelC(f),safetyR(s){}
bool operator>(const Cars& other) const {
int pointA=0, pointB=0;
if (maxspeed>other.maxspeed) {
pointA++;
} else {
pointB++;
}
if (fuelC<other.fuelC) {
pointA++;
} else {
pointB++;
}
if (safetyR>other.safetyR) {
pointA++;
} else {
pointB++;
}
return pointA > pointB;
}
};

int main() {
Cars BMW("BMW",300,5,10);
Cars KIA("KIA",200,4,5);
if(BMW > KIA) {
cout <<"BMW has a higher assessment"<< endl;
}else{
cout <<"KIA has a higher assessment"<< endl;
}
return 0;
}
4❤‍🔥4💊3👍1
شيئية OOP
Photo
Q3/

A/
#include<iostream>
using namespace std;
class Item
{
protected:
string title,author;
int ISBN;
public:
Item(string t,string a,int i):title(t),author(a),ISBN(i){}
virtual void buy(bool p){
cout << "the virtual function" << endl;
}
};
class Book : public Item
{
public:
Book(string t,string a,int i):Item(t,a,i){}
void buy(bool p)
{
if(p)
{
cout<<title<<" by "<<author<<endl<<"ISBN :"<<ISBN<<endl;
}
else
{
cout<<"book unavailable"<<endl;
}
}
};
class DVD : public Item
{
public:
DVD(string t,string a,int i):Item(t,a,i){}
void buy(bool p)
{
cout<<title<<" by "<<author<<endl<<"ISBN :"<<ISBN<<endl;
}
};
int main() {
Book adeq("legend of zelda","ahmed",503);
DVD n("mario songs","marimaker",163);
Item* ptr;

ptr=&adeq;
ptr->buy(true);

ptr=&n;
ptr->buy(0);
}


B/
#include<iostream>
#include<stdexcept>
using namespace std;
class nuclear_reactor
{
protected:
int temperature,pressure;
double radiation_levels;
public:
nuclear_reactor(int t,int p,double r):temperature(t),pressure(p),radiation_levels(r){}

};
class monitoring : public nuclear_reactor
{
public:
monitoring(int t,int p,double r):nuclear_reactor(t,p,r){}
void checktemp()
{
if(temperature>1000)
{
throw "temperature is too high";
}
else cout<<"temperature is normal"<<endl;
}
void checkpressure(){
if (pressure>2000)
{
throw"pressure is too high";
}
else cout<<"pressure is normal"<<endl;
}
void checkrad() {
if (radiation_levels>0.1)
{
throw"high radiation";
}
else cout<<"normal radiation"<<endl;
}
};
int main() {
monitoring a(1100,1700,0.03);
monitoring b(900,1500,0.02);
try{
a.checktemp();
a.checkpressure();
a.checkrad();
}catch(const char* msg)
{
cerr<<msg <<endl;
}
try{
b.checktemp();
b.checkpressure();
b.checkrad();
}catch(const char* msg)
{
cerr<<msg <<endl;
}

}
6