Ressources numériques complémentaires proposées avec vos documents papier.
Partie 1 : Approche historique
Vidéo 1 : SketchPad (1963)
Pour ceux qui veulent en savoir plus, la suite ici.
Code du document 4 :
! dogs.sim ;
Begin
Class Dog;
! The cim compiler requires virtual procedures to be fully specified ;
Virtual: Procedure bark Is Procedure bark;;
Begin
Procedure bark;
Begin
OutText("Woof!");
OutImage; ! Outputs a newline ;
End;
End;
Dog Class Chihuahua; ! Chihuahua is "prefixed" by Dog ;
Begin
Procedure bark;
Begin
OutText("Yap yap yap yap yap yap");
OutImage;
End;
End;
Ref (Chihuahua) d;
d :- new Chihuahua; ! :- is the reference assignment operator ;
d.bark;
End;
Tester dans le compilateur Simula67 en ligne : https://www.tutorialspoint.com/compile_simula_online.php
Partie 2 : Jeu des villageois :
Simulation Begin
Integer seed;
! Utility method for logging messages along with the current simulation
time ;
Procedure log(message); Text message; Begin
OutFix(Time, 2, 0);
OutText(": " & message);
OutImage;
End;
! This is a regular class, used to represent a fishing rod that you can
wait in line for ;
Class FishingRod; Begin
Ref (Head) queue; ! Head is a system class representing a linked list ;
Boolean inUse;
Procedure request; Begin
If inUse Then Begin
Wait(queue); ! This suspends the waiting process ;
queue.First.out;
End;
inUse := True;
End;
Procedure surrender; Begin
inUse := False;
Activate queue.First; ! Start/resume the process ;
End;
queue :- New Head;
End;
Ref (FishingRod) rod;
! The below line declares the class and what we would now call a
constructor ;
Process Class Villager(villagerName); Text villagerName; Begin
! These are local to the operating rule, but are basically our object
fields / instance attributes ;
Integer health;
Real start;
Real finish;
health := 100;
While True Do Begin
! Villagers get hungry after 60 minutes or so, give or take a
standard deviation of 20 minutes ;
Hold(Normal(60, 20, seed));
start := Time;
log(villagerName & " is hungry and requests the fishing rod.");
rod.request; ! Wait for the fishing rod ;
finish := Time;
! If a villager has to wait too long, that villager loses health ;
If finish - start > 5 Then Begin
log(villagerName & " went hungry waiting for the rod.");
health := health - (finish - start) * 2;
If health < 0 Then Begin
log(villagerName & " starved to death waiting for the rod.");
rod.surrender;
Passivate; ! Suspend the process indefinitely ;
End;
End;
! It takes around 12 minutes to catch a fish ;
log(villagerName & " is now fishing.");
Hold(Normal(12, 4, seed));
log(villagerName & " has caught a fish.");
rod.surrender;
End;
End;
rod :- New FishingRod;
Activate New Villager("John");
Activate New Villager("Jane");
Activate New Villager("Betty");
Activate New Villager("Sam");
! Let's wait a full day of simulated time to see what happens ;
Hold(60 * 48);
End;
Télécharger le programme
Voici la sortie du programme.
Tester dans le compilateur Simula67 en ligne : https://www.tutorialspoint.com/compile_simula_online.php
Partie 3 : Evolution de la popularité de la POO :
Vidéo 2 : Most popular languages
Partie 4 : Jeu Qui est-ce ?
Vidéo 3 : Explication du jeu qui est-ce ?
Partie 5 : Problème de la machine à café
Vidéo 1 :
>> Vidéo à télécharger ici.
Vidéo 2 :
Partie 6 : Surcharge d’opérateur
>> Fichier CSV complet des Pokemons
Ecrit par Picassciences
Poster un commentaire