Datentypen

Primitive Datentypen in Inform 7 sind number, text und truth state. Sie entsprechen int, String und boolean. Außerdem kann jede Klasse als Datentyp herangezogen werden. (Arrays gibt es keiner, aber Listen und zweidimensionale Tabellen.)


Ähnlich wie bei Enum in Java kann man auch in Java eigene ennumerated values festlegen:

Colour is a kind of value. Colours are red, green and blue.

Danach kann man colour wie einen anderen Datentyp verwenden.

Max has a colour called favourite colour. The favourite colour of Max is blue.

Man kann auch abkürzend den Bezeichner des neuen Datentypen gleichzeitig als Bezeichner des Attributs verwenden:

Max has a colour. The colour is is blue.

Zulässige Werte für das Colour-Attribut sind red, green und blue, weil colour eben auch ein Datentyp ist, der nur diese Werte kennt.


Referenzdatentypen werden durch “relations” gestaltet. Eingebaut sind unter anderem bereits die Relation to have, to contain, to support, to carry, to wear; man kann weitere definieren (is married to).

[Klassendefinition]
A bank manager is a kind of person.
It has a text called job description. [auch: He has/She has/They have]
It has a number called age.
It has a truth state called busy. Busy is usually true.
[Meist eleganter: A bank manager can be busy or not busy.]
It has a person called lawyer. 

In Java:

class BankManager extends Person {
 String job_description;
 int age;
 boolean busy = true;
 Person lawyer;
}
[Anlegen eines Objekts dazu]
Theo is a bank manager in the bank. 
The job description of Theo is "Big Man".
The age of Theo is 42.
The lawyer of Theo is a woman called Nathalie.

In Java:

BankManager theo = new BankManager();
theo.setLocation(bank);
theo.setJobDescription("Big Man");
theo.setAge(42);
theo.setLawyer(new Woman("Nathalie"));

Benutzen kann man das dann so:

Instead of attacking a bank manager:
	Say "My lawyer's name is [printed name of the lawyer of the noun]."

Operationen auf ganzen Zahlen:
+ oder plus
– oder minus
* oder multiplied by oder times
/ oder divided by

Außerdem gibt es modulo:
remainder after dividing a by b

Runden:
a to the nearest b
z.B. 201 to the nearest 5 (=200), 10:27 AM to the nearest five minutes (= 10:25 AM)


Listen gehen so:

  • Every person has a list of people called friends.
    The friends of Max are {Alex, Bertie, Catharine}

Schreibe einen Kommentar