promotion image of download ymail app
Promoted

java 題目翻譯問題

可以告訴我下列題目的意思嗎?

最好可以舉個例子,謝謝。

還有請不要直接再翻譯器上翻。

題目:

write an inheritance hierarchy for classes Quadrilateral,Trapezoid ,parallelogram,Rectangle

and Square.Use Quadrilateral as the superclass of the hierarchy. Create and use a Point

class to represent the points in each shape. Make the hierarchy as deep(i.e.,as many

levels)as possible.Specify the instance variables and methods for each class.The private

instance variables of Quadrilateral should be the x-y coordinate pairs for the four

endpoints of the Quadrilateral.Write a program that instantiates objects of your classes and

outputs each object's area(except Quadrilateral).

1 Answer

Rating
  • 9 years ago
    Favorite Answer

    - 為Quadrilateral(四邊形),Trapezoid(不等邊四邊形) ,parallelogram(平行四邊形),Rectangle(矩形) Square(正方形)類別編寫一個繼承結構.

    - 使用Quadrilateral為該結構的父類別.

    - 在每個形狀類別裡,建立一個Point的類別來表示每個圖形的頂點.

    - 盡量加深該結構的層級深度.(e.g.祖父類別,父類別,子類別,子孫類別...)

    - 每一個類別裡請詳列該類別裡專有的變數和方法.

    - 在Quadrilateral類別裡,將會有多個私有變數各自表示四邊形裡的四個頂點,每個頂點以x,y座標表示.

    - 請編寫另一程式,可以將上述所有類別實體化(物件),並且輸出每個物件的面積.

    此體目要求深度...

    四邊形為父類別

    不等邊四邊形也是四邊形,所以可以是四邊形的子類別

    平行四邊形也能是不等邊四邊形, 所以是它的子類別

    矩形也是平行四邊形, 所以是它的子類別.

    正方形也算矩形的細分, 所以是它的子類別.

    舉例:

    public class Quadrilateral{

    private Point p1, p2, p3, p4; // 舉例

    // 程式碼...

    }

    public class Trapezoid extends Quadrilateral{

    public void getArea(){ //body }

    // 程式碼...

    }

    public class parallelogram extends Trapezoid{

    public void getArea(){ //body }

    // 程式碼...

    }

    public class Rectangle extends parallelogram{

    public void getArea(){ //body }

    // 程式碼...

    }

    public class Square extends Rectangle{

    public void getArea(){ //body }

    // 程式碼...

    }

    希望這樣友幫到你

    豚仔

    Source(s):
    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.