الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

يا اخوان أريد أن اضيف Constructor لبرنامج وبه طلبات كثيرة

بدأه Haha_saa في 20 ديسمبر 2009 · 3 رد · 575 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

قال صلى الله عليه وسلم ( من فرج عن أخيه كربة من كرب الدنيا فرج الله عنه كربة من كرب يوم القيامة )

أرجوكم مساعدتي في هذا البرنامج ولكم من صادق الدعاء

Q2) write a java class that corresponding to the following instructions:

1. The class name is AB, which inherited from AC. AB class is a leaf class, means can't be inherited any more. This class can be accessed anywhere.

2. Integer x, y, s as primitive data type. y cannot be accessed from out of its class.

3. The default constructor is initializing x to 0 and y to 0 too.

4. Overload the default constructor with z integer argument; assign the z value to the x value.

5. Write method m1 that has no body;

6. Write method m2 that cannot be override. This method returns the power 2 of x value.

7. Write method m3 that has no arguments, it just assign 5 to s, and returns s.

In side the main method initialize the s data type to = zero, then call m3 and println s.

وهذي محاولتي علما بأني شغال بهذا البرنامج من اسبوع


}
abstract final AB extends AC {
int x;
int y;
praivate int s;
AB (int x , int y) {
x=0 ;
x=0 ;
}
AB(praivate int z ){
x=z;
}
abstract void m1 ();
final int m2 (int x )
{ return ( math.pow(x,2));
}
m3 () {
int s = 5 ;
return s ;
}
}
public class BC {
public static void main (String args []){
int s = 0 ;
m3 ();
System.out.println(s);
}
}
class AC {

تم تعديل هذه المشاركة بواسطة herch في 20 ديسمبر 2009 في 20:39 — السبب: الوسم [code]

#2

في البداية قم بترجمة السؤال إلى العربية

في المرة القادمة أرجو أن تختار اسماً أفضل

إن لم تستطع ذلك قم بوضع السؤال في موضوع أسئلتكم واستفساراتكم

تحياتي

1
حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

#3

أحي الكريم شوف هذا الحل

القيمة النهائية ل s سنكون 5

public class AC {
    public AC() {
    }
}



public final class AB extends AC {


 public int x,s;

 private int y;

  public void m1(){

  }

  public double m2(){
        double m=x*x;
        return m;
  } 

  public int m3(){
     int k=5;
    return s=k;


  }
    public AB() {

    x=0;
    y=0;

    }

    public AB(int z) {

    x=z;

 }

}



public class BC {
    public BC() {
    }

    public static void main(String[] args) {
        BC bC = new BC();

    AB f=new AB();
    f.s=0;
    int p=f.m3();
    System.out.println(p);
     System.out.println(f.s);
    }  

}
#4

جزاك الله خير اخي الكريم كريم

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…