en
Feedback
شيئية OOP

شيئية OOP

Open in Telegram

عمي رحمة لوالديك ولعشيرتك وللعزاز وللعراق وللشرق الأوسط، لا تكعد تحفظ الأكواد الكود فهم فهم فهم مو حفظ و السلام

Show more
234
Subscribers
No data24 hours
-47 days
-930 days
Posts Archive
الحل :
#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()
    {
        if(watertemperature<30) {
            throw "water temperature is too low";
        }
        else {
            cout << "water temperature normal" << endl;
        }
    }
};


class Oil : public carengine {
private:
    int oiltemperature;

public:
    Oil(int o = 0):oiltemperature(o){}

    void check()
    {
        if(oiltemperature>75) {
            throw "oil temperature is too high";
        }
        else {
            cout << "oil temperature normal" << endl;
        }
    }
};

int main()
{
    Water check1(20);
    Oil check2(90);

    carengine* eng;
    
    eng = &check1;
    try {
    eng->check();
    } catch(const char* msg) {
        cerr << "Note: " << msg << endl;
    }

    eng = &check2;
    try {
    eng->check();
    } catch(const char* msg) {
        cerr << "Note: " << msg << endl;
    }

    return 0;
}

خل اسوي نفس الي يدورون اتنشن وصلوني 200 لايك و اجيبلكم الحل

كوز اليوم بتاريخ : 2024/4/29
كوز اليوم بتاريخ : 2024/4/29

مقارنة اكبر اصغر ( نفس سؤال المد تقريباً بس هذا من الملزمة )

سؤال اوفر لودنك (مختبر)

جرب تخلي التراي و الcatch بالكلاس

سؤال المختبر

سؤال الاوفرلودنك

الدكتور كال السؤال مضمون 100% يجيبه بالفاينل ف هذا سؤال من اسئلة الفاينل ادرسوه جيداً💀 هو صح كال راح اجيبه ما ينحل بس نحاول و الله كريم

حل السؤال
#include <iostream>
using namespace std;

class Bank {

public:
    double balance;

    void deposit(double amount) {
        if (amount > 0) {
            balance += amount;
        }
        else {
            throw "can't deposit a negtive value";
        }
    }

    void withDrawing(double amount) {
        if (balance >= amount) {
            balance -= amount;
        } else {
            throw "can't withDrawing more money than your balance";
        }
    }

    void display() {
        cout << "your Balance: " << balance << endl;
    }
};

int main() {
    Bank s1 = {350};

    try {
        s1.deposit(-5);
    } catch (const char* msg) {
        cerr << "Error: " << msg << endl;
    }

    try {
        s1.withDrawing(400);
    } catch (const char* msg) {
        cerr << "Error: " << msg << endl;
    }

    s1.display();

    return 0;
}

photo content

الفراغات ما متأكد منهن 100% ف يمكن اغيرهن

السؤال الأول / 1- instance 2- memory 3- name 4- member 5- this -> 6- early 7- virtual , implementation ☆●☆ السؤال الثاني /
#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;
}
☆●☆ السؤال الثالث /
#include<iostream>
using namespace std;
class customer
{
protected:
    string name;
    int phonenumber;
    int credit;
public:
    customer(string n,int ph,int c):name(n),phonenumber(ph),credit(c){}
    virtual void call() {
    cout << " virtual calling " << endl;
    };

};
class prepaid : public customer
{
public:
    prepaid(string n,int ph,int c):customer(n,ph,c){}
    void call() {
            cout<<"prepaid make call"<<endl;
            }
};
class postpaid : public customer
{
public:
    postpaid(string n,int ph,int c):customer(n,ph,c){}
    void call()
    {
        cout<<"postpaid make call"<<endl;
    }

};
int main()
{
    prepaid call1("memo",3579,300);
    postpaid call2("oeom",2468,600);
    customer* ptr=&call1;
    ptr->call();
    ptr=&call2;
    ptr->call();
}

اسئلة mid-term الهياكل الشيئية OOP بتاريخ : 2024/4/22
+1
اسئلة mid-term الهياكل الشيئية OOP بتاريخ : 2024/4/22

#include <iostream>
using namespace std;

class Box {

private:
    double length;
    double breadth;
    double height;

public:
    Box(double l, double b, double h) {
    length = l;
    breadth = b;
    height = h;

}

double Volume() {
return length * breadth * height;
}

int compare(Box box) {
return this->Volume() > box.Volume();
}

};


int main(void)
{
Box Box1(3.3, 1.2, 1.5);
Box Box2(8.5, 6.0, 2.0);
if(Box1.compare(Box2)) {
cout << "Box2 is smaller than Box1" <<endl;
}
else {
cout << "Box2 is equal to or larger than Box1" <<endl;
}

return 0;
}
هاي من الملزمة بس اتوقع يجيبها لأن ما طبقناها

منا وانت نازل مادتنا لهذا الكورس : أمثلة الكوز اسئلة المختبر ال18 سؤال اسئلة من العام السابق و بالنسبة لشروحات المادة ف اليوتيوب مليئ بالمقاطع تابع الي تفهم عليه +انا ناشر لعادل نسيم : في نهاية القائمة ( بوينتر، رفرنس، ستركت، Inline ) : https://youtube.com/playlist?list=PLCInYL3l2AajFAiw4s1U4QbGszcQ-rAb3&si=3vYmdgld5-Dwv_UF شرح لـ OOP : https://youtube.com/playlist?list=PLCInYL3l2Aaiq1oLvi9TlWtArJyAuCVow&si=RPVhIKrXhbp-a8Il

الي بالملاحظة سويته باستخدام البوينتر كفكرة اخذوها

#include <iostream>
using namespace std;

class cakestore{
public:

    virtual void print()
    {
        cout<< "this is cake store"<<endl;
    }
};


class chocolate: public cakestore {
public:

    void print() {
    cout<< "chocolate cake" << endl;
    }
};


class vanilla: public cakestore {
public:

    void print() {
    cout<< "vanilla cake" << endl;
    }
};


int main() {

    chocolate typechocolate;
    typechocolate.print();

    vanilla typevanilla;
    typevanilla.print();

    /*
    cakestore *caketype;

    chocolate typecake;
    caketype = &typecake;
    caketype->print();

    vanilla typevanilla;
    caketype = &typevanilla;
    caketype->print();
    */

    return 0;
}

سؤال مختبر البرمجة بتاريخ: 2024/4/20
سؤال مختبر البرمجة بتاريخ: 2024/4/20

نفس فكرة وطريقة الملزمة :
#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 3.14 * radius * radius;
 }
};


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

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

 double area() {
 return length * width;
 }
};


int main() {
    Shape *Shape;
    Circle circle(5);
    Rectangle rectangle(4, 6);
   
    Shape = &circle;
    cout << "Area in Circle : " << Shape->area() << endl;
    Shape = &rectangle;
    cout << "Area in Rectangle : " << Shape->area() << endl;
    
 return 0;
}