السلام عليكــم ورحمـة الله وبركاتــه ،،
- Write a Mobile class, which contains three attributes: colour, make, and model.
- All attributes should be represented as strings.
- The model and make of a mobile are not modifiable
- All mobiles are made by Nokia (i.e. the make is the same for all mobiles)
- All attributes should be represented as strings.
- Write a constructor for the class.
- If you were not able to write a default constructor, what do you think is the reason for this inability?
- Are there any attributes that cannot be initialized inside the constructor? What are they?
- If you were not able to write a default constructor, what do you think is the reason for this inability?
- Add three methods (member functions) to the class:
- First method should be called ring which displays on the screen "ring! ring! ring!". This method should not change any of the attributes values.
- First method should be called ring which displays on the screen "ring! ring! ring!". This method should not change any of the attributes values.
- Second method prints on the screen the mobile's description (colour, make and model of the mobile.)
- Second method prints on the screen the mobile's description (colour, make and model of the mobile.)
- Last method is called changeCover, which sets the colour of the mobile to a given colour.
- Last method is called changeCover, which sets the colour of the mobile to a given colour.
- Add another method (member function) called isTheSame which takes a Mobile object as a parameter. It should return true if the given Mobile object is the same as this mobile. Two mobiles are the same if they have the same make and model.
- Test your class by creating a silver, Nokia, 6600 mobile object. Then send it a message to display its information.
Change the cover of the mobile to a red one, then again send it a message to display its information.
Create another black, Nokia, 3310 mobile object, then ask it if it was the same as the first mobile (the one you have created above).
- Change the isTheSame method in question 4 to be a global function that is a friend of the class.
- Do you need to change the parameters and why?
- Change the test case in question 5 to reflect the modification of the function.
- Do you need to change the parameters and why?
أريد شرح الفقرة الرابعة مشكورين =)
الذي فهمته من هذه الفقرة يريد ان انشأ دالة وارسل لها كائن من المين
وداخل الدالة انشأ شرط اذا كان الكائن المرسل نفس الـمواصفات بس ما فهمت مواصفات ايش !! :blink: اذا الشرط صحيح ارجع قيمة صحيحة واذا خطأ ارجع قيمة خاطئة
هل فهمي للسؤال صحيح !! شكرا للجميعـ :blush: ـ