شيئية OOP
Photo
Q1/
1-instance
2-blueprint
3-constructor
4-inheritance
5-encapsulation
Q2/
Q3/
Q4/
Q5/
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();
}
❤1
شيئية OOP
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…
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;
}
}
❤1👏1
هندسة الحاسبات - المرحلة الأولى²⁰²⁴⁻²⁰²³ :
كورس اول :
Programming and Problem Solving
كورس ثاني :
Object Oriented Programming and Data Structure
كورس اول :
Programming and Problem Solving
كورس ثاني :
Object Oriented Programming and Data Structure
❤1
شيئية OOP
CoE 113 Programming and Problem Solving.pdf
1.8 MB
programming and problem solving ²⁵
🤣2🔥1
شيئية OOP
البرمجة : ملزمة دفعة²⁵ + حلول الواجبات: https://t.me/Q_code_cpp/311 شروحات: شرح كامل للغة Cpp من الصفر: https://youtube.com/playlist?list=PLEPx7DrqAqKAJm4wM3r7FvvX7y6tuBOAQ&si=moNpvaL7IPGRFJv8 شرح المتسلسلة سؤال 31: https://t.me/no_zero_any_more/359 طريقة…
البرمجة :
5 فراغات
5 البوابات المنطقية
20 من اول 50 سؤال ( ملف ال75 سؤال )
10 مصفوفات
10 فنكشن
والاسئلة مراح تطلع من اطار ال75 سؤال
كل التوفيق ان شاء الله بحق محمد وآل محمد نشوفكم ناجحين ونفرح بيكم🐧🤍♥️
5 فراغات
5 البوابات المنطقية
20 من اول 50 سؤال ( ملف ال75 سؤال )
10 مصفوفات
10 فنكشن
والاسئلة مراح تطلع من اطار ال75 سؤال
كل التوفيق ان شاء الله بحق محمد وآل محمد نشوفكم ناجحين ونفرح بيكم🐧🤍♥️
شيئية OOP
Photo
Q1/A
1-(X+=Y)=57
2-(X||Y)=1(True)
3-(X!=Y)=1(True)
4-(X^=4)=34
5-(X»=4)=2
Q1/B
1-Instructions
2-logical
3-sizeof
4-continue
5-start
Q2/A
Q2/B
Q3/A
Q3/B
Q4/
Q5/
1-(X+=Y)=57
2-(X||Y)=1(True)
3-(X!=Y)=1(True)
4-(X^=4)=34
5-(X»=4)=2
Q1/B
1-Instructions
2-logical
3-sizeof
4-continue
5-start
Q2/A
#include<iostream>
using namespace std;
int main () {
for(int i=50;i<=65;++i) {
if (i==57||i==62)continue;
cout<<i<<',';
}
return 0;
}
Q2/B
#include<iostream>
using namespace std;
int main() {
int salary,performance_rating,years_of_service;
float bonus=0;
cin>>salary>>performance_rating>>years_of_service;
if(years_of_service>=5) {
if (performance_rating>8) {
bonus=20;
}else {
bonus=10;
}
}else {
if (performance_rating>8) {
bonus=10;
}else {
bonus=5;
}
}
cout<<"bonus:"<<bonus<<'%'<<endl;
return 0;
}
Q3/A
#include<iostream>
using namespace std;
int main () {
char drink_size;
cin>>drink_size;
switch (drink_size) {
case 's':
cout<<"small";
break;
case'm':
cout<<"medium";
break;
case'l':
cout<<"large";
case'x':
cout<<"extra large";
default:
cout<<"size not available";
}
return 0;
}
Q3/B
#include <iostream>
using namespace std;
int main() {
int A[3][4]={{3,4,6,1},{4,8,0,9},{5,7,1,2}};
int B[4][3];
for (int i=0; i<3;i++)
{
for (int j=0;j<4;j++)
{
B[j][i]=A[i][j]; // The main idea of the code
}
}
for(int i=0;i<4;i++)
{
for (int j=0;j<3;j++)
{
cout<<B[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
Q4/
#include<iostream>
using namespace std;
int power(int base,int exponent) {
int ans=1;
for (int i=1;i<=exponent;i++) {
ans*=base;
}
return ans;
}
int fact(int n) {
int f=1;
for (int i=1;i<=n;i++) {
f*=i;
}
return f;
}
int main() {
double x,n,sum=0;
cin>>x>>n;
for (int i=0;i<n;i++) {
sum+=power(x,i)/fact(i);
}
cout<<sum;
}
Q5/
#include<iostream>
using namespace std;
int mostf(int a[],int s) {
int m=a[0];
int c=0;
for (int i=0;i<s;i++) {
int counter=0;
for (int j=0;j<s;j++) {
if (a[i]==a[j]) {
counter++;
}
}
if (counter>c) {
c=counter;
m=a[i];
}
}
return m;
}
int main() {
int ar[8]={1,6,3,6,3,4,6,5};
cout<<mostf(ar,8);
}
❤2
https://youtube.com/playlist?list=PLEPx7DrqAqKAJm4wM3r7FvvX7y6tuBOAQ&si=moNpvaL7IPGRFJv8
بنهاية هاي القائمة موجود شرح عن OOP
من فيديو 131
بنهاية هاي القائمة موجود شرح عن OOP
من فيديو 131
YouTube
C++ For College Students
دورة كاملة لتعلم البرمجة بلغة ++C مكونه من اكثر من 200 محاضرة فيديوية مدعومة بعدد كبير من الامثلة مناسبة للمبتدئين و خصوصا الطلبة الجامعيين في اختصاصات علوم ...
👍1