المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ارجو المساعده



Man msn
06-11-2004, 11:56 PM
السلام عليكم ورحمة الله وبركاته

اخواني الاعزاء اريد مساعدتكم في حل هذا السؤال وجزاكم الله خيرا










import java.awt.Point;


























public class TestContainer {


























static public void main (String [ ] args) {


















Ball b1 = new Ball (new Point (20, 10), 10);


Container con1 = new Container (b1);


System.out.println ("con1 coords equal " + con1.hasEqualCoords ()); // 1


System.out.println ("con1 x " + con1.getBall ().location ().x); // 2


con1.swapCoords (); // 3


System.out.println ("con1 y " + con1.getBall ().location ().y);


}


}










import java.awt.Point;


























public class Container {


























protected Ball aBall;


























public Container (Ball b){ aBall = b; }


























public boolean hasEqualCoords () {


























return (aBall.location ().getX () == aBall.location ().getY ());


















}










public Ball getBall () { return aBall; }


























public void swapCoords (){


















Point p;










int temp;


















p = aBall.location ();


temp = p.x;


p.x = p.y;


p.y = temp;


}


}

والسؤال يقول









Give the output of the program when run and explain what takes place when the


















lines marked //1, //2 and //3 are executed.










انا جربته وطلعلي التالي









con1 coords equal false
con1 x 20
con1 y 20



واللي ابي اعرفه شلون راح اشرح الكود بالتفصيل في 1و2و3 مثل ما السؤال طالب يعني منو المسج ومنو راح يستلمه؟؟؟


شاكرلكم تعاونكم معاي مقدما وانشالله يستمر بينا هالتعاون المثمر


تحياتي

اخوكم بالاسلام

والسلام عليكم ورحمة الله وبركاته

احمد رجوب
15-10-2010, 11:55 PM
الحمد لله كثيرن كثيثرن