An overview of this course can usually be found at starting out of: http://wwwi.wu-wien.ac.at/Studium/.
Rony G. Flatscher, As of: 2004-10-26
Hint: The formula for converting Celsius to Fahrenheit is:
Fahrenheit = Celsius*(9/5)+32
Hint: The formula for converting Celsius to Fahrenheit is:
                Celsius = (Fahrenheit-32)*(5/9).
Hint: The formula for converting Celsius to Fahrenheit is:
Fahrenheit = Celsius*(9/5)+32
Hint: The formula for converting Celsius to Fahrenheit is:
                Celsius = (Fahrenheit-32)*(5/9).
E.g. the invocation euro Ats 65 Dem should convert 65 Austrian Schillings into Deutsche Mark. If no target currency is given, then the amount should be converted to all Euro currencies, including the Euro itself.
Hint: starting with 1999-01-01 all Euro currencies are set to a fixed exchange rate with respect to one Euro (in 2001-01-01 the Greek Drachmen joined the Euro currency system) as follows:
| 1 | EUR | 13,760300 | ATS | 
| 1 | EUR | 40,339900 | BEF | 
| 1 | EUR | 1,955830 | DEM | 
| 1 | EUR | 5,945730 | FIM | 
| 1 | EUR | 6,559570 | FRF | 
| 1 | EUR | 0,787564 | IEP | 
| 1 | EUR | 1.936,270000 | ITL | 
| 1 | EUR | 40,339900 | LUF | 
| 1 | EUR | 2,203710 | NLG | 
| 1 | EUR | 200,482000 | PTE | 
| 1 | EUR | 166,386000 | ESP | 
| 1 | EUR | 340,750000 | GRD | 
In addition:
UNKNOWN_INPUT_CURRENCY or
UNKNOWN_OUTPUT_CURRENCY, if the user enters an unknown Euro currency.
Define an ADT EURO which has the following attributes and functions/procedures, examples relate to the Austrian currency "Schilling":
currency: stores the currency's name, e.g.
ATS for the Austrian Schilling.
country: stores the country's name, e.g.
Austria.
denotation: stores the name of the currency in
the country's language, e.g. Schilling.
exchangeRate: stores the currency amount which is
equivalent to 1 EUR (cf. table in excercise 7), e.g.
13.7603.
Currency2Euro: retrieves the currency amount as an
argument and returns the equivalent Euro amount.
Euro2Currency: retrieves the Euro amount as an argument
    and returns the equivalent currency amount.
With the help of initialisation of new objects, the attributes denotation,
exchangeRate, country and currency should get their
values assigned to.
After creating such Euro objects one can use them to carry out the conversion calculations.
The following statements:
yield the following output:
    /* arguments: "currency", "country", "denotation" and "exchangeRate" */
    o = .euro ~ NEW("ATS", "Austria", "Schilling", 13.7603)
    SAY o~denotation o~exchangeRate o~country o~currency
    SAY
    SAY "100" o~currency "are:" o~currency2euro(100) "EUR"
    SAY "100 EUR are:"          o~euro2currency(100) o~currency
    Schilling 13.7603 Austria ATS
    100 ATS are: 7.26728342 EUR
    100 EUR are: 1376.0300 ATS
Currency2Euro and Euro2Currency are not needed anymore and therefore can be removed.
EURO objects only:
    currency,
    country,
    denotation and
    exchangeRate.
Hint for solving this particular demand:
If a METHOD directive is processed by the interpreter, then in effect
it will create two methods: one for setting a value in an attribute
("assignment"/"set" method) and one for getting the value stroed in an attribute
("access"/"get" method).
Example for defining an attribute xyz with the help of a
METHOD directive:
   ::METHOD xyz ATTRIBUTE 
Given the above directive the interpreter will create the following two methods, before the program
starts:
   ::METHOD XYZ  /* get method, returning the present attribute's value */
     EXPOSE XYZ  /* establish access to attribute         */
     RETURN XYZ  /* return value stored with attribute    */
   ::METHOD "XYZ=" /* set method, assigning a new value to the attribute */
     EXPOSE  XYZ   /* establish access to attribute       */
     USE ARG XYZ   /* retrieve argument and assign it to the attribute */
In order to solve this task you need to make sure that the values for the attributes are set in the
INIT method.
Next, do not use method directives with the keyword ATTRIBUTE,
rather create the needed "get" methods to retrieve the attribute's values yourself.
EURO object shall receive an attribute for storing the
euro_amount: if the amount is changed, then the euro_amount shall be
re-calculated and vice versa (a change in the euro_amount automatically causes the
amount to be re-calculated).
For this purpose define the following two new attributes:
amount and
euro_amount.
If creating a new EURO object an optional fifth argument should be
allowed which - if given - sets the initial value of the amount attribute. If this
argument is not given, then make sure that amount and euro_amount are set
to 0.
Hint for solving this particular demand: define the get and the set method yourself!
With the help of initialisation of new objects, the attributes denotation,
exchangeRate, country, currency and, optionally,
amoutn should get their values assigned to.
After creating such Euro objects one can use them to carry out the conversion calculations, by
merely setting the value of the attribute amount or euro_amount and
afterwards getting the value of the other attribute.
The following statements:
yield the following output:
    /* arguments: "currency", "country", "denotation" and "exchangeRate" */
    o = .euro ~ NEW("ATS", "Austria", "Schilling", 13.7603)
    SAY o~denotation o~exchangeRate o~country o~amount o~currency  o~euro_amount "EUR"
    SAY
    o~amount = 100       -- set currency amount
    SAY o~amount o~currency "are:" o~euro_amount "EUR"
    o~euro_amount = 100  -- set euro amount
    SAY o~euro_amount   "EUR are:" o~amount o~currency
    Schilling 13.7603 Austria 0 ATS 0 EUR
    100 ATS are: 7.26728342 EUR
    100 EUR are: 1376.0300 ATS
After sorting out the bag, you should be able to tell how many fruits there were in the bag, and how many pieces there are for each kind of fruit.
For our excercise the content of the bag should consists exactly of:
"apple",
"apple",
"pear",
"strawberry",
"apple",
"banana",
"plum",
"plum",
"banana",
"apple",
"pear",
"melon",
"peanut",
"peanut",
"peanut",
"peanut",
"peanut",
"apple",
"peanut",
"pineapple",
"banana",
"plum",
"pear",
"pear",
"plum",
"plum",
"banana",
"apple",
"pear",
"melon",
"peanut",
"peanut",
"peanut",
"apple",
"peanut",
"pineapple",
"banana",
"peanut",
"peanut",
"peanut",
"peanut",
"peanut",
"apple",
"peanut",
"pineapple",
"banana",
"peanut",
"melon",
"mango",
"peanut",
"peanut",
"apple",
"peanut",
"pineapple",
"banana",
"pear"
According to this content the output should look like:
Total of fruits in bag: 56
consisting of:
                 plum:   5
           strawberry:   1
                 pear:   6
                melon:   3
               banana:   7
                mango:   1
               peanut:  20
            pineapple:   4
                apple:   9
Devise a program which solves this problem.
Make sure that you list the ordered fruits in exactly the following (alphabetic) order:
According to the content as given in excercise 16 the output now should look like as follows:
Received Fruits (ordered)
                 plum
                 pear
                apple
               banana
Received Fruits (not ordered)
               peanut
           strawberry
                melon
                mango
            pineapple
Received Fruits (ordered)
                apple:   9
               banana:   7
                 pear:   6
                 plum:   5
Received Fruits (not ordered)
               peanut:  20
           strawberry:   1
                melon:   3
                mango:   1
            pineapple:   4
Devise a program which solves this problem.
"Manager" "Manager":
Managed_Objects available. It
contains all objects created from that class.
Broadcast which forwards the
received message object to all collected objects.  An optional second argument can contain the value
.true, which will make sure that the received message object will be
dispatched synchroneously (it gets the message SEND).
Hints:
SEND, then your program
will wait until the method in the target object has executed ("synchroneous" execution).
START, then your program
receives immediately control again and can proceed executing (multithreaded execution,
"asynchroneous" execution).
Message.)
       An example program, which uses this needed metaclass:
   /* solution_17.rex */
   .test~~new("Anton") ~~new("Berta") ~~new("Caesar") -- create three instances
   SAY "Before synchroneous broadcast..."
   .test~broadcast( .message~new(.nil, "say_info"), .true )
   SAY "after synchroneous broadcast."
   SAY
   SAY "Before Asynchroneous broadcast..."
   .test~broadcast( .message~new(.nil, "say_info"))
   SAY "after asynchroneous broadcast."
   ::REQUIRES "solution_17.cls"
   /* --------------------------- Test-Class -------------------------------- */
   ::CLASS test            METACLASS Manager 
   /* --------------------------- Class Methods ----------------------------- */
   ::METHOD Init           CLASS 
     EXPOSE counter
     counter=0
     self~init:super
   ::METHOD count          CLASS 
     EXPOSE counter
     counter=counter+1
     RETURN counter
   /* --------------------------- Instance Methods -------------------------- */
   ::METHOD Init
     EXPOSE  name number
     USE ARG name
     number=self~class~count
     self~init:super
   ::METHOD name                 ATTRIBUTE
   ::METHOD say_info 
     EXPOSE number
     SAY " SAY_INFO - name:" self~name "created as #" number
A possible output:
   Before synchroneous broadcast...
   Manager.Broadcast: invoking messages synchroneously...
    SAY_INFO - name: Caesar created as # 3
    SAY_INFO - name: Berta created as # 2
    SAY_INFO - name: Anton created as # 1
   after synchroneous broadcast.
   Before Asynchroneous broadcast...
   Manager.Broadcast: invoking messages asynchroneously...
   after asynchroneous broadcast.
    SAY_INFO - name: Caesar created as # 3
    SAY_INFO - name: Berta created as # 2
    SAY_INFO - name: Anton created as # 1
Devise the needed metaclass.