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

[مخالف - طلب حل : ]الرجاء المساعدة في حل السؤال

مغلق
بدأه wathek في 9 نوفمبر 2011 · 2 رد · 603 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

Q2.1: Write a Java program according to the following specifications:

(a) Develop an interface ShapeInterface to the following specifications:

• The interface includes one method: public double getArea(). Later when getArea() is implemented in a class, it should return a number representing the area of the relevant shape.

(b) Develop a public abstract class Shape to the following specifications: (4 marks)

• The class implements ShapeInterface.

• The class has two private instance variables: int x, and int y .

• Accessor and mutator methods should be implemented for all instance variables.

© Develop a public class Circle to the following specifications: (4 marks)

• The class is a subclass of Shape.

• The class has a private instance variable int radius.

• The class has a three-argument constructor that sets the values of x, y, and radius to given values.

• The class has a one-argument constructor that sets the values of rad to given value, and x and y to zeros. This should be done by invoking the above three-argument constructor using this keyword.

(d) Develop a public class Rectangle to the following specifications: (4 marks)

• The class is a subclass of Shape.

• The class has two private instance variables int height and int width.

• The class has a four-argument constructor that sets the values of x, y, width and height to given values.

• The class has a two-argument constructor that sets the values of width and height to given values, and x and y to zeros. This should be done by invoking the above four-argument constructor using this keyword.

(e) Both Circle and Rectangle classes should: (8

• override toString() in java.lang.Object to return a string representation of the instance variables in the relevant class.

• include implementation of any further mandatory methods.

• include accessor and mutator methods for all instance variables.

Q2.2: Develop a class ShapesTest to test the classes in Q2.1. The class ShapesTest will only have the main method that should: (4 marks)

• Create a Circle instance using the three argument constructor.

• Create a Rectangle instance using the two argument constructor, and sets the values of the remaining variables using the mutator methods.

• Print on the screen the values of the instance variables of the two above instances using toString().

Q2.3: Answer the following questions: (4 marks)

(a) Can we instantiate objects of the type Shape? Justify your answer.

(b) Do we have to override getArea()in Shape class (you may try this on NetBeans)? Justify your answer

#2

السلام عليكم:

أخي هل جربت حل السؤال؟

إبدا في الحل وسنساعدك بإذن الله

#3

الأخ الكريم/الأخت الكريمة

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

مرحباً بكم في منتدى الفريق العربي للبرمجة

تأسف إدارة المنتدى لغلق الموضوع وذلك لمخالفته قوانين المشاركات، فقرة طلب حل الواجبات والتمارين.

قواعد طرح المشاركات

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

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

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

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

728x90.png

هذا الموضوع مغلق.

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