TOPIC H: Types.

Contents :

Ordinal Types: enums, subranges.
Ordinal Operators: INC, DEC, MIN, MAX, ORD, VAL
Types
CASE, LOOP
Standards!

Exercises :

Wat uitleg over topic H

D1: Agenda.


S1: Datastructuur

Een datastructuur gebruik je om alle informatie over een bepaald 'ding' bij te houden. Stel dat je een voetbalspel wilt programmeren:
  1. Definieer een datastructuur die 1 voetballer voorstelt met de volgende eigenschappen:
  2. Definieer een variabele die 2 ploegen (bezoekers & thuis) van 11 spelers bevat.

S2: Screens from BW to RGB.

The display of a computer (screen) is by nature a 2D object. Therefore it is represented in a similar way inside computer programs. Try to imagine a type that could be used to represent the values of the pixels of a screen. This means that you should be able to say : "the pixel at position (x,y) with have the value z". Choose the best Modula-2 structure for each kind of screen:
  1. A pure black and white screen, meaning that a pixel is either on of off. There is nothing in between!
  2. A so called paper white screen. These screens could light up a pixel with 256 different levels of intensity. The value 0 meant that the pixel was completely black (off).
  3. The first colors screens where limited to 16 different colors (these are the colours of graph.def): BLACK , BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, WHITE, GRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN,  LIGHTRED, LIGHTMAGENTA, LIGHTYELLOW, BRIGHTWHITE.
  4. Modern screens (and graphics cards) can handle more colors using 3 color components per pixel: RGB. Each component of a pixel can have 256 different levels of intensity.




S3: Agenda Continued.

copy the code of D1
  1. Print the agenda in the following format:
  2. Change the agenda that it only takes weekdays.
  3. Print a report with the number of hours of each activity.
  4. Make a procedure that searches in the agenda for n consecutive (opeenvolgende) free hours in a given day. The procedure prints the resulting free hours.

S4: Date.

  1. Create a datatype that can contain a date (year, month, day number, weekday).
  2. Make a procedure that checks if a date is possible (check the number of days in a month, eg 31th April), you may ignore the leap-days (schrikkeldagen).
  3. Make a procedure that prints the date as "Friday, 14/11/2003".




S5: Right-Angled Triangles (rechthoekige driehoeken)

  • Define a datastructure which can contain triangles (length of the sides (zijden) & angles (hoeken)). Fill it.
  • Check if it is a right-angled triangle (rechthoekige driehoek), indicate this with a boolean.
  • A       B       C        a         b        c
    5,30    7,80    16,73    30        60       90
    9,37    8,53    12,67    30        60       90
    10,63   8,00    7,00     90        60       30

    (with a, b and c the angles opposite (tegenover) to respectively (respectievelijk) sides A, B and C)




    X1:





    H1:




    H2:





    T1: Output

    MODULE TopicOTest1;
    FROM IO IMPORT WrLn, WrCard, RdCard;

    BEGIN

    END TopicOTest1.