موقع طلبة جامعة البحرين

يمكنك تصفح الموقع كزائر ولكن ندعوك لتسجيل عضوية خاصة بك لتحصل على كافة الصلاحيات مثل تنزيل ملفات المكتبة وقراءة تعليقات هيئة التدريس وغيرها. يمكنك الحصول على عضوية مجانية بالضغط على زر تسجيل. إذا قمت بالتسجيل مسبقا فيمكنك الضغط على زر دخول.

تسجيل دخول
  • قسم المكتبة الجامعية مغلق مؤقتا بعد الاستهداف التي تعرضت له بعض خدمات أمازون في البحرين، جاري استرجاع الملفات ونقلها إلى سيرفرات جديدة وسيتم بعدها اعادة افتتاح المكتبة

ITCS215 للفصل الدراسي الأول 2015 - 2016

كان سهل احس .. سويت زين
بس انا سويت روحي كلش وما عدت على التري وتخربط في البوست اوردر ..
اما سالفة كلجين ما كلجين :RpS_huh: هذي ما مرت عليي :RpS_huh: تعرّفت عليها في الامتحان وخليت ما سويت شي :nosweat:

فنكشن التري .. هالدرس شرحه يوم احتفالات الجامعة و كلنا غايبين
بس شفت اسئلة سابقه عليه و عرفت ليه
آخر لحظة غيرت في الفنكشن جزء و احس غيرت لغلط :nosweat:

الامتحان مباشر لو يقسمون الدرجه؟
 
فنكشن التري .. هالدرس شرحه يوم احتفالات الجامعة و كلنا غايبين
بس شفت اسئلة سابقه عليه و عرفت ليه
آخر لحظة غيرت في الفنكشن جزء و احس غيرت لغلط :nosweat:

الامتحان مباشر لو يقسمون الدرجه؟

ما اعتقد مباشر لأن اقل سؤال عليه 10 .. وهم 6 اسئلة وبعضهم عليهم 12
 
الامتحان من 80

يعني قسمة 2

احسه كان حليو بس ماندري اخاف تطلع الدرجة زفت
 
الحين في سؤال tree
كان مطلوب left child or right child لو left child and right child
????????????????:whistling::rolleyes2:
 
السلام عليكم
خير ما ابدأ به


بِسْمِ اللّهِ الرَّحْمَنِ الرَّحِيمِ
قَالَ رَبِّ اشْرَحْ لِي صَدْرِي وَيَسِّرْ لِي أَمْرِي وَاحْلُلْ عُقْدَةً مِّن لِّسَانِي يَفْقَهُوا قَوْلِي
صدق الله العلي العظيم

بِسْمِ اللّهِ الرَّحْمَنِ الرَّحِيمِ
أَلَمْ نَشْرَحْ لَكَ صَدْرَكَ {1} وَوَضَعْنَا عَنكَ وِزْرَكَ {2} الَّذِي أَنقَضَ ظَهْرَكَ {3} وَرَفَعْنَا لَكَ ذِكْرَكَ {4} فَإِنَّ مَعَ الْعُسْرِ يُسْرًا {9} إِنَّ مَعَ الْعُسْرِ يُسْرًا {6} فَإِذَا فَرَغْتَ فَانصَبْ {7} وَإِلَى رَبِّكَ فَارْغَبْ {8}
صدق الله العلي العظيم

من المشاركين ان شاء الله وياكم
:smile:

انا في سكشن 2 دكتور نبيل حويحي

نسأل الله التوفيق لنا ولكم

​
 
التعديل الأخير:
  • Like
التفاعلات: Memm
السلام عليكم
شخباركم مع المادة ؟

اعتقد بعد مرور 4 ايام دوام كل السكاشن بدايتهم كانت مع الـTemplates ( الي كان ملغي في ال104 )
احنا سكشن 2 خذينا النوع الاول من الـTemplates وكان سهل
وباجر بناخذ النوع الثاني
واعتقد الاسبوع الجاي بندخل في محتوى المقرر

موفقين جميعا
#اول مشاركة لي في المنتدى
​
 
Templates
هي اداة تتيح لنا استخدام (Class او Function او....الخ) واحد لاي نوع من المتغيرات ( int ,double ,char ,.....etc )
حسب ما قال لنا الدكتور مطلوب نعرف شلون نستخدم
Function templates
Class templates

اولا : Function templates

Q: Write a C++ program to Comparison between tow integers (3,4) and tow double (2.2 , 1.2) by using Function template .


نستطيع حل السؤال بهذه الطريقة :-
كود:
int Max (int x, int y) {  
 if (x<y)     
   return y;   
 return x;
}

double Max (double x, double y) {  
 if (x<y)     
   return y;   
 return x;
}

لكن لكي لا نكرر الفنكشن مرتين نستخدم التمبليت

من اجل انشاء template نكتب
كود:
template <class myType>
حيث بمكن استبدال myType باي شيء اخر
وسيكون هو الاسم البديل لنوع المتغير

كود:
myType Max (myType x, myType y)
ثم نكتب الفنكشن بالصورة الاعتيادية
ويكون المتغير في الفنكشن من النوع الذي كتبناه في السطر السابق
وفي حالتنا هو myType

ثم نكمل كتابة الفنكشن حسب ما هو مطلوب في السؤال

وفي ال Main
من اجل الاتصال بالفنكشن
نستخدم السطر التالي في حالة الانتيجر
كود:
c=Max<int>(a,b);
حيث
C ستكون القيمة الذي سنحصل عليه من الفنكشن
(a,b) القيم المرسلة للفنكشن
Max اسم الفنكشن
<int> نوع القيم الذي ارسلناه للفنكشن

وفي حالة الdouble
سيصبح السطر
كود:
 c=Max<double>(a,b);

كود حل السؤال بالكامل

كود:
#include <iostream>
using namespace std;
template <class myType>
myType Max (myType x, myType y) {
   if (x<y)
     return y;
   return x;
}
int main (){
     int a=3,b=4,c;
     c=Max<int>(a,b);
     cout<<c<<endl;
     double q=2.2,w=1.2,z;
     z=Max<double>(q,w);
     cout<<z<<endl;
     system("Pause")   ;
    return 0;     
}


ساحاول شرح ال Class templates لاحقا
بالتوفيق جميعا
وعذرا على اي خطء في اللغة

​
 
دكتورنا ما درسنا عن الـtemplates + ما شفتهم مطلوبين بالخطة
مباشرة دخل معانا في ال inheritance و الـcomposition
 
Ruthless
​

بالفعل هو مو موجود معانا في الخطة
لكن كان ملغي علينا في ال 104
وحسب ما شفت محتوى المقرر
تبين لي ان في 50% من الأسئلة راح نستخدمه
مثل الكلاس والبوينتر
و د: نبيل حويحي لما عرف انه كان ملغي في ال104 قال لازم اول شي نشرحه لكم قبل ما ندخل في محتوى المقرر
 
^^^
Thanks IT Batman ..

إذا إستمر الدكتور على نفس شرح اللكجر لي طاف وقلل سرعته شوي

Very perfect​
 
R.NaDaL
welcome
--------------------------------------
النوغ الثاني من الـtemplates

Class templates

لا يفرق كثيرا عن الفنكشن تمبليت
حيث نكتب قبل الكلاس
template <class type>
حيث ان type اسم نوع المتغير
ويمكن تغير الاسم الى ما تريده
وفي داخل اكلاس نستطيع نستخدم هذا الاسم لاي متغير
مثال :
كود:
template <class type>
class marks{ 
   type arr[7];
   int index;
 public:
   marks();     
   void insert(type m);
   void print();
   ~marks();
};

كما هو واضح استخدت اري من نوع type داخل الكلاس

في الامبلمنتيشن
كذالك نضع السطر التالي قبل كل فنكشن
template <class type>
نفس الحال في الكونستركتر والديسكرتر

مثال في الكونستركتر
template <class type>
marks<type>::marks() {
index=0;
}

في شغلة مهمة
قبل الكلاس نقدر نخلي اي متغير من اي نوع في سطر التمبليت
ونقدر نستخدم المتغير في الكلاس
مثال
كود:
template <class type , int size = 5>

لكن في الامبلمنتيشن
لا تكتب القيمة ونوع المتغير في السطر الذي يسبق الفنكشن
فيصبح السطر هكذا
كود:
template <class type ,size>



وفي ال Main
اذا اردنا ان ننشاء كلاس بمتغيرات من نوع int نكتب
كود:
class name <int>name;

حيث
class name هو اسم الكلاس
name هو الاسم المتغير من نوع الكلاس
والint i هو نوع المتغير الذي داخل الكلاس

وفي حالة double
كود:
class name <double >name;
وكذالك مع الانوع الاخرى من المتغيرات

عموما من اجل التوضيح
لكم هذا المثال

Q : write C++ program to find the sum of 7 marks
you should input the marks to the class and print it
remember the marks can be in integers or double type
and the output should by like that

img.php


كود:
#include <iostream>
using namespace std;
template <class type>
class marks { 
   type mark[7];
   int index;
 public:
   marks();     
   void insert(type m);
   void print();
   ~marks();
};
template <class type>
   marks<type>::marks() {
   index=0;
}
template <class type>
void marks<type>::insert(type m)
{
   mark[index]=m;
   index++;
}
template <class type>
void marks<type>::print() {    
     type sum=0;
     for (int i=0;i<7;i++)
        sum+=mark[i];
     for (int i=0;i<7;i++)
        cout<<" "<<mark[i];
     cout<<"  "<<sum<<endl;
}
     
template <class type>
marks<type>::~marks() {
    }


int main ()
{  
  int x;
  cout<<"Hi"<<endl; 
  cout<<"If your marks are in type int press 1"<<endl;
  cout<<"If your marks are in type double press 2"<<endl;     
  cin>>x;
  if (x==1)
  {
    marks<int>student;
    int mr;
    cout<< " Enter the 7 marks "<< endl;
    for ( int i=0 ; i<7;i++)
    {  cin>>mr;
       student.insert(mr);
    }
    cout<<"the marks and sum  = ";
    student.print();
    student.~marks();
  }
  if (x==2)
  {
    marks<double>student;
    double mr ;
    cout<< " Enter the 7 msrks "<< endl;
    for ( int i=0 ; i<7;i++)
        {cin>>mr;
         student.insert(mr);
        }
    cout<<"the marks and sum  = ";
    student.print();
    student.~marks();   
  }
  else 
  cout<<"soory ";
system("Pause");
return 0;     
}

بالتوفيق جميعا
وعذرا على اي تقصير​
 
التوفيق شعب
 
هذا اول تطبيق لي في هالماده .. على الـCompositions

PHP:
#include <iostream>
using namespace std;

class engine
{
    private:
    int epower;
    double eliter;
    public:
    engine(int ep,double el);
    void setengine(int ep,double el);
    void printe();
};

class vehicle
{
    private:
    int vmodel;
    string vname;
    engine e;
    public:
    vehicle(int vm,string vn,int ep,double el);
    void setvehicle(int vm,string vn,int ep,double el);
    void printv();
};

engine::engine(int ep,double el)
{
    epower=ep;
    eliter=el;
}

void engine::setengine(int ep,double el)
{
    epower=ep;
    eliter=el;
}

void engine::printe()
{
    cout<<"The engine power is: "<<epower<<endl;
    cout<<"The engine liter is: "<<eliter<<endl;
}

vehicle::vehicle(int vm,string vn,int ep,double el):e(ep,el)
{
    vmodel=vm;
    vname=vn;
}

void vehicle::setvehicle(int vm,string vn,int ep,double el)
{
    e.setengine(ep,el);
    vmodel=vm;
    vname=vn;
}

void vehicle::printv()
{
    cout<<endl;
    cout<<"The Vehicle Name Is: "<<vname<<endl;
    cout<<"The Vehicle Model Is: "<<vmodel<<endl;
    e.printe();
}

int main()
{
    vehicle v(2010,"Maxima",350,6.0);
    v.printv();
    return 0;
}

لحد الحين اشوف الماده اسهل من ITCS102-104

ماندري بعدين يصجونا بويش

..

نسألكم الدعاء
 
شباااب الفزعه .. ابي اعرف وين المشكله .. مللني

هذا السؤال

PHP:
class bankAccount
{
 public:
   void setNumber(int num);
   void setBalance(double num);
   int getNumber();
   double getBalance();
   void deposit (double d);
   void withdraw(double w);
   void print();//print the account number and the balance
   bankAccount(int n, double b);
 private:
   int number; // account number
   double balance;
};
 
Derive a class checkingAccount from the class bankAccount (public inheritance) with the following members:
(a) private data members:
- interest (double)
- minimumBalance (double)
- serviceCharges (double)
(b)public member functions:
- functions to set the interest, the minimum balance, and the service charges.
- functions to get the interest,  the minimum balance, and the service charges.
- checkBalance() to apply service charges (new balance will become old balance – service charges), if the balance falls below the minimum balance and return true, otherwise returns false. 
- print() to print the account information (including the information of the base class bankAccount).
- A constructor with 5 parameters.
 
Implement all the member functions of the class checkingAccount.

وهذي محاولتي للحل .. بالإضافه ابغي اعرف شلون استخدم الـGet فنكشن في الـDerive Class .. وشكراً

PHP:
#include <iostream>
using namespace std;

class bankAccount
{
private:
   int number; // account number
   double balance;

 public:
   void setNumber(int n);
   void setBalance(double b);
   int getNumber(int&n);
   double getBalance(double&b);
   double deposit (double d);
   double withdraw(double w);
   void print();//print the account number and the balance
   bankAccount(int n, double b);
};

class checkingAccount:public bankAccount
{
    private:
        double Interest;
        double MinimumBalance;
        double ServiceCharges;
    public:
    void setInterest(double in);
    void setMinimumBalance(double mb);
    void setServiceCharges(double sc);
    double getInterest(double&in);
    double getMinimumBalance(double&mb);
    double getServiceCharges(double&sc);
    double checkBalance(double NB);
    void printcheckingBalance();
    checkingAccount(double in,double mb,double sc,int n,double b):bankAccount(n,b)
};

bankAccount::bankAccount(int n,double b)
{
    number=n;
    balance=b;
}

void bankAccount::setNumber(int n)
{
    number=n;
}

void bankAccount::setBalance(double b)
{
    balance=b;
}

int bankAccount::getNumber(int&n)
{
    return n;
}

double bankAccount::getBalance(double&b)
{
    return b;
}

double bankAccount::deposit(double d)
{
    balance+d;
    return d;
}

double bankAccount::withdraw(double w)
{
    double newbalance;
    newbalance=balance-w;
    return newbalance;
}

void bankAccount::print()
{
    cout<<"The Account Number is: "<<number<<endl;
    cout<<"The Account Balance is: "<<balance<<endl;
}

void checkingAccount::setInterest(double in)
{
    Interest=in;
}

void checkingAccount::setMinimumBalance(double mb)
{
    MinimumBalance=mb;
}

void checkingAccount::setServiceCharges(double sc)
{
    ServiceCharges=sc;
}

double checkingAccount::getInterest(double&in)
{
    return in;
}

double checkingAccount::getMinimumBalance(double&mb)
{
    return mb;
}

double checkingAccount::getServiceCharges(double&sc)
{
    return sc;
}

/*
double checkingAccount::checkBalance(double NB)
{
    if(getBalance()>ServiceCharges)
    {
        NB=getBalance()-ServiceCharges;
    }
    else return -1;

    return NB;
}
*/

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
 
^
شنو بالضبط المشكلة اللي تواجهها؟

بالنسبة لإستخدام الـGet function
دام انت حاط return value ما يحتاج تحط parameters في هذي الحالة
الـparameters راح تحتاجهم إذا كان نوع الفنكشن void
مثلاً الكود هذا
PHP:
double bankAccount::getBalance(double&b)
{
    return b;
}
راح يكون جذي
PHP:
double bankAccount::getBalance(){ return balance; }
وتعدل الـprototype
 
  • Like
التفاعلات: xrom
^
شنو بالضبط المشكلة اللي تواجهها؟

بالنسبة لإستخدام الـGet function
دام انت حاط return value ما يحتاج تحط parameters في هذي الحالة
الـparameters راح تحتاجهم إذا كان نوع الفنكشن void
مثلاً الكود هذا
PHP:
double bankAccount::getBalance(double&b)
{
    return b;
}
راح يكون جذي
PHP:
double bankAccount::getBalance(){ return balance; }
وتعدل الـprototype

دايماً في الفنكشن get ما يحتاج parameters .. دايركت نسحب الـ object من الداتا ممبز ..​
 
  • Like
التفاعلات: xrom
كان قصدي لو مثلاً نسوي get function وحدة بس لكل المتغيرات اللي بالكلاس
في هالحالة راح تكون void function with parameters
 
  • Like
التفاعلات: xrom
عودة
أعلى أسفل