en
Feedback
شيئية OOP

شيئية OOP

Open in Telegram

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

Show more
234
Subscribers
No data24 hours
-47 days
-930 days
Posts Archive
Q6/
#include<iostream>
using namespace std;

class SecuritySystem{
protected:
    bool MotionDetection;
    string DoorWindow_Status;
    int FireSmoke_Levels;

public:
    SecuritySystem(bool MD, string DWS, int FSL): MotionDetection(MD), DoorWindow_Status(DWS), FireSmoke_Levels(FSL) {}
};

class HomeSecurity : public SecuritySystem {
public:
    HomeSecurity(bool MD, string DWS, int FSL): SecuritySystem(MD, DWS, FSL) {}

    void checkMD(){
    if(MotionDetection){
        throw "there is a Motion";
    }
    else
        cout << "there is no Motion" << endl;
    }

    void checkDWS(){
    if(DoorWindow_Status == "open") {
        throw "the Door and Window are not closed";
    }
    else
        cout << "the Door and Window are close" << endl;
    }

    void checkFSL(){
    if(FireSmoke_Levels > 50) {
        throw "the fire and somkes levels are not normal";
    }
    else
        cout << "the fire and somkes levels are normal" << endl;
    }
};


int main() {
HomeSecurity home1( false, "closed", 23);

try {
    home1.checkMD();
    home1.checkDWS();
    home1.checkFSL();
} catch(const char* msg){
        cerr << msg <<endl;
    }
}

Q1/ 1-instance 2-blueprint 3-constructor 4-inheritance 5-encapsulation Q2/
#include <iostream>
using namespace std;
class Circle{
protected:
    float radius;

public:
    Circle(float r):radius(r){}
};

class Cylinder : public Circle{
private:
    float height;

public:
    Cylinder(float r,float h):Circle(r),height(h){}

    float volume(){
        return (3.14*radius*radius*height);
    }
};

int main(){
    Cylinder c(3.5,6.1);
    cout<<c.volume();
}
Q3/
#include <iostream>
using namespace std;

class smart_phone{
    int battery_life,camera_quality,user_interface;
    
public:
    smart_phone(int b,int c,int u):battery_life(b),camera_quality(c),
    user_interface(u){}
    
    bool operator > (smart_phone iphone){
        int  s_score=0,i_score=0;
        
        if(battery_life>iphone.battery_life)s_score++;
        else i_score++;
        
        if(camera_quality>iphone.camera_quality)s_score++;
        else i_score++;
        
        if(user_interface>iphone.user_interface)s_score++;
        else i_score++;
        
        return s_score>i_score;
    }
};
int main(){
    smart_phone samsung(9,9,9);
    smart_phone iphone(1,1,1);
    
    if(samsung>iphone)cout<<"first phone is superior";
    else cout<<"second phone is superior";
}
Q4/
#include <iostream>
using namespace std;

class bank {
private :
    string AccountHolderName;
    int AccountNumber;
    double balance;
public:
    bank ( string AH, int AN,  double B) {
        AccountHolderName = AH;
        AccountNumber = AN;
        balance = B;
    }

    void deposit (double amount) {
        balance += amount;
   }
   
   void withDrawal(double amount);

   friend void display (bank bank);
};

 void bank::withDrawal(double amount) {
        balance -= amount;
   }

void display (bank bank) {
   cout << "your balance is : " << bank.balance << endl;
   };


int main()
{
    bank client = {"mogo", 78904, 1090};

    client.deposit(24.5);
    client.withDrawal(9.5);
    display(client);
    return 0;
}
Q5/
#include <iostream>
using namespace std;

class Vehicle {
protected:
    string Make;
    int Model,LicensePlate;
public:
    Vehicle(string m,int mo,int l)
    : Make(m), Model(mo), LicensePlate(l) {}
    virtual void rent(){
    cout << "the virtual function" << endl;
    };
};

class Car : public Vehicle {
    bool serviced;
public:
    Car(string m,int mo,int l, bool s)
    : Vehicle(m,mo,l), serviced(s) {}
    void rent(){
        if (serviced) {
            cout<<"Car rented successfully"<<endl;
        } else {
            cout<<"Car cannot be rented"<<endl;
        }
    }
};

class Truck : public Vehicle {
public:
    Truck(string m, int mo, int l)
    : Vehicle(m, mo, l) {}
    void rent(){
        cout<<"Truck rented"<<endl;
    }
};

int main() {
    Car c("crown",2000, 61947, true);
    Truck t("Ford",2010 , 13512);

    Vehicle* ptr;

    ptr = &c;
    ptr->rent();

    ptr = &t;
    ptr->rent();

}

اسئلة الهياكل OOP / الدور الثاني
+1
اسئلة الهياكل OOP / الدور الثاني

هذا كذلك يعتبر جواب للـ Q6\B
هذا كذلك يعتبر جواب للـ Q6\B

Q4/ A -
#include <iostream>
using namespace std;

int fun(int a) 
{ 
return a;
}

int main() {
    cout<<fun(5);
}
👇همين يعتبر حل حبيته هيج :
#include <iostream>
using namespace std;

string fun(string a ) { 
return a;
}

int main() {
    cout<<fun( " نجحنا واليحبنا يفرح ويانا ");
}
B - سؤال 33
#include <iostream>
using namespace std;
int main ()
{
char grade ;
cout << " take one from this ( A , B, C, D, F) ";
cin >> grade;
switch(grade)
{
case 'A' :
cout << "Excellent!" << endl;
break;
case 'B' :
cout << "Well done" << endl;
break;
case 'C' :
cout << "done" << endl;
break;
case 'D' :
cout << "You passed" << endl;
break;
case 'F' :
cout << "Better try again" << endl;
break;
default :
cout << "Invalid grade" << endl;
}
cout << "Your grade is " << grade << endl;
return 0;
}
ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ Q5/ A -
#include<iostream>
using namespace std;

int Sum(int a[],int s)
{
    int sum = 0;
    for (int i = 0; i < s; i++) {
        int current_item = a[i];
        bool unique_ = true;
        for (int j = 0; j < s; j++) {
            if (i != j&&current_item == a[j]) {
                unique_ = false;
            }
        }
        if (unique_)sum += a[i];
    }
    return sum;
}
int main() {
    int i[8] = {1,2,3,2,3,4,2,5};
    cout << Sum(i,8);
}
B -
#include<iostream>
using namespace std;

double product(int a,double d){
return a*d;
}
int main() {
    cout<<(2,1.5);
}
ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ Q6/ A -
#include<iostream>
using namespace std;

int power(int base, int pow) {
    if (pow == 0)
        return 1;
    else if (pow == 1)
        return base;
    else
        return base * power(base, pow - 1);
}

int main() {
    cout << power(3, 3);
    return 0;
}
B -
#include<iostream> 
using namespace std; 
 
double calculateSin(double x, int n)  
{ 
    double result = 0; 
    double term = 1; 
    int sign = 1; 
 
    for (int i = 1; i <= n; ++i)  
 { 
        result += sign * term; 
        sign = -sign; 
        term *= (x * x) / ((2 * i) * (2 * i + 1)); 
    } 
 
    return result; 
} 
 
int main()  
{ 
    double x; 
    int n; 
 
    cout << "Enter the value of x in radians: "; 
    cin >> x; 
 
    cout << "Enter the number of terms in the Taylor series approximation: "; 
    cin >> n; 
 
    double sinApproximation = calculateSin(x, n); 
 
    cout << "Approximation of sin(" << x << ") using Taylor series with " << n << " terms: " << sinApproximation << endl; 
 
    return 0; 
}

Q1 / A- 1) 21 2) 1 3) 1 4) 8 5) 48 B- 1- relational 2- logical 3- ( &= ) 4- continue 5- beginning ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ Q2/ A - يشبه سؤال 2
#include <iostream>
using namespace std;

int main()
{
    int a = 5, b = 10;
    cout << "Before swapping: a = " << a << ", b = " << b << endl;

    a = a + b;
    b = a - b;
    a = a - b;

    cout << "After swapping: a = " << a << ", b = " << b << endl;

    return 0;
}
B - سؤال 4
#include <iostream>
using namespace std;

int main()
{
    float sum=0;
    float average;
    float number [6];
    cout<< " enter the six number : "<<endl;
    for (int i = 0; i < 6; i++)
    {
        cout<<" number "<<i+1<<" : ";
        cin>>number[i];
        sum += number[i];
        average = sum/6;
    }
    cout<<" the sum "<<sum<<endl;
    cout<<" the average "<<average<<endl;
    return 0;
}
ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ Q3/ A - 6 سؤال
#include <iostream>
using namespace std;
int main ()
{
int a = 11;
while ( a <= 29)
{
cout<<a<<", ";
a += 2;
}
return 0;
}
B - سؤال 16
#include <iostream> 
using namespace std; 
 
int main()  
{ 
    char character; 
 
    cout << "Enter a character: "; 
    cin >> character; 
 
    if ((character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z'))  
 { 
        switch (character)  
  { 
            case 'a': 
            case 'e': 
            case 'i': 
            case 'o': 
            case 'u': 
            case 'A': 
            case 'E': 
            case 'I': 
            case 'O': 
            case 'U': 
                cout << character << " is a vowel." << endl; 
                break; 
            default: 
                cout << character << " is a consonant." << endl; 
        } 
    }  
 else  
 { 
        cout << "Invalid input. Please enter a valid alphabet character." << endl; 
    } 
 
    return 0; 
}

اسئلة البرمجة الدور الثاني
+1
اسئلة البرمجة الدور الثاني

الهياكل OOP : شروحات : في نهاية القائمة ( بوينتر، رفرنس، ستركت، Inline ) : https://youtube.com/playlist?list=PLCInYL3l2AajFAiw4s1U4QbGszcQ-rAb3&si=3vYmdgld5-Dwv_UF شرح لـ OOP : https://youtube.com/playlist?list=PLCInYL3l2Aaiq1oLvi9TlWtArJyAuCVow&si=RPVhIKrXhbp-a8Il الحفظيات : https://t.me/Q_code_cpp/243 حلول الـ Exercises الـ 18 سؤال : https://t.me/Q_code_cpp/141 اسئلة المختبر : المختبر الأول : ( كان من الملزمة بوينتر ، رفرنس ، ستركتر ) . المختبر الثاني : https://t.me/Q_code_cpp/69 المختبر الثالث : https://t.me/no_zero_any_more/949 المختبر الرابع : https://t.me/Q_code_cpp/90 المختبر الخامس : https://t.me/Q_code_cpp/163 المختبر السادس : https://t.me/Q_code_cpp/174 المختبر السابع : https://t.me/Q_code_cpp/186 الكوز الأول : https://t.me/Q_code_cpp/67 الكوز الثاني : https://t.me/Q_code_cpp/197 اسئلة المد + الحل : https://t.me/Q_code_cpp/180 بالنسبة لمد المختبر فكان من ال18 سؤال . اسئلة الفاينل + الحل : https://t.me/Q_code_cpp/257 فاينل المختبر : https://t.me/Q_code_cpp/212 حلول : https://t.me/Q_code_cpp/214 https://t.me/Q_code_cpp/215 اسئلة الدور الثاني : https://t.me/Q_code_cpp/298 حل اسئلة الدور الثاني : https://t.me/Q_code_cpp/301 https://t.me/Q_code_cpp/302 بعض الأمثلة من عندي الي شفت الدكتور تكلم عنها او لمح لها : https://t.me/Q_code_cpp/168 https://t.me/Q_code_cpp/218 https://t.me/Q_code_cpp/251

اسئلة الفاينل / البرمجة وحل المشاكل شرح العمليات المنطقية : https://t.me/no_zero_any_more/373 Q1 / A - 1) 16 ( لان عملية ناقص
+1
اسئلة الفاينل / البرمجة وحل المشاكل شرح العمليات المنطقية : https://t.me/no_zero_any_more/373 Q1 / A - 1) 16 ( لان عملية ناقص - - بجهة اليمين ف ما تشتغل ) 2) 1 ( يعني true لان عملية جمع منطقية بوابة OR ) 3) 0 ( يعني false لان مقارنة هاي اذا x يساوي y وهن غير متساويات) 4) 2 ( باقي القسمة لان y/x = 16/8 و ناتجها 2 ) 5) 4 ( هاي شفت العنصر مرة واحدة بجهة اليمين ( موضوع اللوجك بالكورس الثاني التشفيت) بالباينري 8 = 1000 ، شفت مرة وحدة تصير 0100 = 4 ) B - 1- relational operator ( ص26 ) 2- logical operator ( ص28 ) 3- ^= موجود بـ ( ص29) 4- break 5- end

اسئلة المد / البرمجة وحل المشاكل ملاحظة/ سؤال 1، هذا حفظ من الفصل الأول يولي حذفه شرح العمليات المنطقية : https://t.me/no_zer
+1
اسئلة المد / البرمجة وحل المشاكل ملاحظة/ سؤال 1، هذا حفظ من الفصل الأول يولي حذفه شرح العمليات المنطقية : https://t.me/no_zero_any_more/373 Q2 / 1) 6 ( هاي شفت العنصر مرتين بجهة اليمين ( ال y = 25 بالباينري 11001 تشفتها مرتين تصير 00110 = 6 ) 2) 20 هاي مقارنة بين البتات هيج تصير x = 1101 , y = 11001 نساوي بينهن x = 01101 y = 11001 هسه نقارن مرتبة الx ويه الy واذا متشابهات الناتج صفر و اذا مختلفات الناتج واحد ف تصير 10100 وهاي تساوي 20 3) 1 ( ويعني true لان يكلك x لا يساوي y وهذا صحيح لان x = 13 و y = 25 ) Q3 / 1- sizeof 2- Bool 3- operating system

75 c++ exercises.cpp

البرمجة : المادة : الفصل الثاني فقط . شروحات : شرح المتسلسلة سؤال 31 : https://t.me/no_zero_any_more/358 طريقة عمل اللوب باستخدام الفنكشن فقط : https://t.me/no_zero_any_more/360 سؤال سلسلة تايلور للساين : https://t.me/no_zero_any_more/362 انواع الفنكشن الاربع : https://t.me/no_zero_any_more/364 شرح سؤال 74 مهم جداً : https://t.me/no_zero_any_more/371 كل العمليات الرياضية والمنطقية الي بل برمجة : https://t.me/no_zero_any_more/373 شرح سؤال 51 : https://t.me/no_zero_any_more/379 الفديوهات على اليوتيوب : https://www.youtube.com/channel/UCQCagTCsQ2eIYYCPOCngTIQ/ الأكواد 75 سؤال : الـ 75 كاملة بحل أحد الطلبة : https://t.me/Q_code_cpp/266 بطريقة حلي : من هذا الرابط لحد سؤال 50 فقط : https://t.me/Q_code_cpp/2 سؤال 51 : https://t.me/Q_code_cpp/58 سؤال 52 : https://t.me/Q_code_cpp/59 اسئلة عن الـ Function : https://t.me/Q_code_cpp/56 https://t.me/Q_code_cpp/57 اسئلة الـ Array : https://t.me/no_zero_any_more/326 قوانين رياضية بصيغ برمجية : https://t.me/no_zero_any_more/345 اسئلة المد : https://t.me/Q_code_cpp/268 اسئلة الفاينل : https://t.me/Q_code_cpp/270 اسئلة الدور الثاني : https://t.me/Q_code_cpp/281 حل اسئلة الدور الثاني : https://t.me/Q_code_cpp/290 https://t.me/Q_code_cpp/291 https://t.me/Q_code_cpp/294

ملاحظة/ الاسئلة تنحل بأكثر من طريقة لذلك كل شخص و طريقته و تكون صحيحة ان شاء الله مو شرط نفس الطريقة

الحل مقدم من أحد الطلبة 〔 〕

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;
    }

}

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;
}

Q1/ 1-Instance 2-Blueprint 3-Alias 4-Nullptr 5-Overloading 6-early binding 7-Abstraction 8-abstract data type 9-encapsulation 10-problem

اسئلة فاينل الهياكل OOP بتاريخ : 2024/5/22
+1
اسئلة فاينل الهياكل OOP بتاريخ : 2024/5/22

الكوز هو وحش الهياكل لان طبق بيه مواضيعنا كلها تقريباً ( بدون الاوفرلودنك طبعاً ) فعملياً هذا الي يطبقه و يفهمه وضعه كلش حلو باجر