Virtual robotics: the playing card robot → Edition



Elementary instructions

Take the pack of cards from the table
Put the pack of cards back on the table
Draw 1 card from the pack of cards
Put the card back in the pack of cards
Display "It's heart
Display "It's diamond
Display "It's club
Display "It's spade


Is the card from hearts?
Is the card from diamonds?
Is the card from clubs?

Controle structures


Virtual robotics: the playing card robot → Execution


Running the program

Step-by-step execution

Test conditions

Initial test conditions...

Test result

Test result...

The playing card robot : statement

You have to create a program that enables the playing card robot to work properly. The robot has to draw one card from a pack of cards and display which kind of card it is: heart, diamond, club or spade.

To code your program, you have a number of commands at your disposal that the robot understands:

Your program (code) must be created by dragging the various elements from the "shoe" on the right to the magnetic board on the left. The few basic rules for arranging the various elements (syntax rules) are explained in the "Help" section.

The code you create will be considered correct if the 4 runtime tests are successful (the corresponding buttons have all turned green at the same time).

Tip: if you want to insert a line in your code, just click on the number of the line you want to free on the magnetic board.

Good work and good success.

N'oubliez jamais que les erreurs sont plus formatives que les succès,
pour autant qu'on se donne la peine d'en comprendre les causes.

◊ ◊ ◊

The playing card robot: help

Building your program code

All you have to do is drag the various elements provided in the "shoe" and arrange them in the right order on the magnetic board on the left of the screen.

You can always move the elements in this way if you want to change your code.

There is no set order for composing your code; you can start at the end but, in the end, your program will have to comply with the layout rules (syntax rules) defined below.

Syntax rules

By convention, the following elements must stand alone on their lines of code:
- Basic action instructions;
- The "ELSE";
- The "END IF";
- The "REPEAT" (later);
- And the "END WHILE" (later).

Condition structure

To check which side of the coin is visible when it is caught, you can construct a condition as follows.
For line 1, if the face-up side is "Tail", the result will be "True". If the face-up side is "Head", the result will be "False". For line 2 (later), it's the other way round.
Note that the "IF", the Check and the "THEN" have to be in the same line.

Tricks and tips

Before After clicking on number 2
Clicking on a line number in the magnetic board will free up that line so that a code element can be inserted.

To remove an item from the magnetic panel, simply place it on the bin and it will disappear the next time you click on the "Organize" button.

◊ ◊ ◊

© Rupert Meurice de Dormale 2024 (update of the 1995 version)

All rights reserved. Copying in whole or in part prohibited without written permission of the author.

The drawings of the robots are by Jean-Baptiste Sonnet.