mirror of
https://github.com/ganelson/inform.git
synced 2024-07-18 06:54:26 +03:00
27 lines
2.1 KiB
Plaintext
27 lines
2.1 KiB
Plaintext
** Making the verb "to weigh"
|
|
(Weighbridge; Dimensions)
|
|
This example draws together the previous snippets into a working implementation of the weighbridge.
|
|
|
|
The following is not a very sophisticated approach, because it does not allow for weight to accumulate: if we put a gold ingot into a paper bag, then put the bag on the balance platform, only the bag's weight will register. But it will do for a first try.
|
|
|
|
{*}"Dimensions"
|
|
|
|
A length is a kind of value. 10m specifies a length. An area is a kind of value. 10 sq m specifies an area. A length times a length specifies an area.
|
|
|
|
A weight is a kind of value. 10kg specifies a weight. Everything has a weight.
|
|
|
|
The verb to weigh means the weight property. A thing usually weighs 1kg.
|
|
|
|
Definition: A thing is light if its weight is 3kg or less.
|
|
|
|
Definition: A thing is heavy if its weight is 10kg or more.
|
|
|
|
The Weighbridge is a room.
|
|
|
|
A blackboard is in the Weighbridge. "A blackboard propped against one wall reads: '122/10 is [122 divided by 10] remainder [remainder after dividing 122 by 10]; 122kg/10kg is [122kg divided by 10kg] remainder [remainder after dividing 122kg by 10kg]; 122kg/10 is [122kg divided by 10] remainder [remainder after dividing 122kg by 10].'" The blackboard weighs 10kg.
|
|
|
|
A feather and a lead pig are in the Weighbridge. The lead pig weighs 45kg.
|
|
|
|
The balance platform is a supporter in the Weighbridge. "The balance platform is 10m by 8m, giving it an area of [10m multiplied by 8m], currently weighing [the list of things on the platform]. The scale alongside reads: [total weight of things on the platform]. [if two things are on the platform]Average weight is: [the total weight of things on the platform divided by the number of things on the platform]. Heaviest item is [the heaviest thing on the platform], at [weight of the heaviest thing on the platform]. Lightest item is [the lightest thing on the platform], at [weight of the lightest thing on the platform].[otherwise]It seems to be able to weigh several things at once."
|
|
|
|
Test me with "get feather / put it on platform / look / get pig / put it on platform / look". |