-1

我无法理解这些术语的含义,如果有人可以向我解释,我将不胜感激。

我已经有 3 个类叫做:Shape Rectangle Circle

然后我创建了一个名为 Triangle 的类

a)当他们说创建一个与矩形 ADT 类似的三角形 ADT 规范(在我已经拥有的类之上)时,这是什么意思

b) 实现类 Triangle

4

2 回答 2

0

“创建三角形ADT的规范”意味着定义定义三角形所需的数据(三个笛卡尔坐标是最直接的,但它可以是一个点、三个角和一个边长,或其他)。

“实现类 Triangle”意味着编写一个 java 类,implements Shape但其内部实现是您在步骤 1 中定义的 java 表示。

于 2012-09-06T03:18:55.350 回答
0

ADT:实现独立的数据描述,指定数据的内容、结构和合法操作。ADT 有一个

Name:
Description of the data structure:
Operations:

Construction operations:
Initial values;
Initialization processes;
    For each operation:
    Name of the operation;

Input: External data that comes from the user of this data (client)

Preconditions: Necesssary state of the system before executing this operation;

Process: Actions performed by the data

Output: Data that is output to the client

Post Conditions: State of the system after executing this operation

例子:

ADT circle
Data: r³ 0 (radius);
Operations

    Costructor:

        Initial values:radius of circle;
        Process: Assign initial value of r;

    Area:

        Input: none;
        Preconditions: none;
        Process: A ¬ p *r*r Output: A
        Postcondition: none

    Circumference:

        Input: None;
        Preconditions: none;
        Process: C ¬ 2*p *r
        Output: C
        Postconditions: none;

End ADT circle; 
于 2012-09-06T03:19:31.193 回答