Join us on Discord!
You can help CodeWalrus stay online by donating here.
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - compsystems

#1
Hello, sorry for my bad English  :-[

The following is a very simple game, the classic guess or deduce a number.

But there is a problem when deploying message in the terminal window, the last messages are not displayed, hopefully in future versions the development group of hpprime solve this problem


Code in Spanish  :-|
EXPORT AdivinarODeducir_Numero()
//test CAS Version: 1.1.2-11 and Operating System: version 6.2.9200
begin
     // Definición de Variables y tipo de contenedor
     local intentos := 0;
     local total_intentos := 0;
     local num_ingresado :=  0;
     local num_secreto := IP( random ( 1, 100 ) );
     
     print();
     print( "*** Ejecución Iniciada. ***" ); freeze;
     wait;
     
     // Presentación
     print( "Juego Matemático versión 0.8" );
     wait;
     print( "El programa genera un número real entre 1 y 100. Trate de deducirlo como recomendación en 8 intentos como máximo" );
     wait;
     
     // Entrada de Datos
     print( "Ingrese el # de intentos personalizados" );
     //freeze;
     wait( 1 );
     if NOT(input( total_intentos,"Total de Intentos","Intentos=","Digite un # como máximo total de intentos" ))
         then
         kill;
     end;
     wait;
     total_intentos := abs(total_intentos); // si el usuario ingresa números negativos se corrige
     print( "Intento #" + total_intentos);
     wait;
     intentos := total_intentos;
     
     print( "solo para hacer pruebas num aleatorio=" + num_secreto); // elimine esta sentencia para jugar verdaderamente
     wait;
     
     if NOT( input( num_ingresado,"Deducir_Numero","Num Ingresado=","Cual es el numero?" ) )
         then kill;
     end;
     print( ">"+num_ingresado );
     
     while( num_secreto <> num_ingresado and intentos > 1 ) do
         if num_secreto > num_ingresado then
             print( "El numero deducido es MENOR que el numero en cuestión" );
             wait;
             else
             print( "El numero deducido es MAYOR que el numero en cuestión" );
             wait;
         end;
         print("");
         
         intentos := intentos - 1; // decrementa en 1 el número de intentos
         print( "Le quedan "+intentos+" intento(s):" );
         print("Intento #" + intentos);
         //freeze;
         wait;
         if NOT( input( num_ingresado,"Deducir_Numero","Num Ingresado=","Cual es el numero?" ) ) then
             kill;
         end;
         print( ">"+num_ingresado );
     end;
     
     if num_secreto <> num_ingresado then
         print( "Perdió! trato en "+ ( ( total_intentos + 1 ) - intentos ) + " intento(s.) :~(, pero el numero era: "+ num_secreto);
         else
         print( "Gano! Usted lo dedujo en: "+ ( ( total_intentos + 1 ) - intentos ) +" intento(s.)" );
     end;
     print( "*** Ejecución Finalizada. ***" );
     
     //freeze;
     return "Done";
     
end;


Video showing the failure

Powered by EzPortal