これらの用語の意味を理解するのに苦労しています。誰かが説明してくれたら幸いです。
私はすでに次の3つのクラスを持っています:Shape Rectangle Circle
次に、Triangle というクラスを作成します。
a) Rectangle ADT に似た Triangle ADT の仕様を作成すると彼らが言うとき、それはどういう意味ですか (私が既に持っている上記のクラス)
b) クラス Triangle を実装する
これらの用語の意味を理解するのに苦労しています。誰かが説明してくれたら幸いです。
私はすでに次の3つのクラスを持っています:Shape Rectangle Circle
次に、Triangle というクラスを作成します。
a) Rectangle ADT に似た Triangle ADT の仕様を作成すると彼らが言うとき、それはどういう意味ですか (私が既に持っている上記のクラス)
b) クラス Triangle を実装する
「三角形ADTの仕様を作成する」とは、三角形を定義するために必要なデータを定義することを意味します (3 つのデカルト座標が最も簡単ですが、1 つの点、3 つの角度、辺の長さ、またはその他のものである可能性があります)。
「クラス Triangle を実装する」とは、Java クラスを作成することを意味しますimplements Shape
が、その内部実装は、ステップ 1 の定義の Java での表現です。
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;