% Démonstration de l'utilisation du Compte est Bon.
% On choisit au hasard 6 plaques parmi 1,2,3,4,5,6,7,9,10,25,50,75,100.
% La solution est choisie au hasard entre 100 et 999.
% Seules les quatres opérations arithmétiques (+,-,*,/) sont autorisées
% et les résultats sont des entiers.

% JBR. Collège de Saussure. 4-3-98.

% Initialisation
plaques=[1:10,25,50,75,100];
nbp=length(plaques);
pla1=0;
pla2=0;
opc=' ';
preminter=1;

% Ecran de jeu
jeu = figure('Units','points', ...
	'Color',[0.8 0.8 0.8], ...
	'NumberTitle','off', ...
	'Name','Le compte est bon', ...
	'Position',[100 200 477 380], ...
	'resize','off',	...
	'Tag','jeu');
t_resultat = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[45 346 180 24], ...
	'HorizontalAlignment','left', ...
	'FontSize',18, ...
	'Style','text', ...
	'String','Il faut trouver:');
t_solution = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[45 216 180 24], ...
	'HorizontalAlignment','left', ...
	'FontSize',18, ...
	'Style','text', ...
	'String','Votre solution:');
t_message = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[305 346 100 24], ...
	'HorizontalAlignment','left', ...
	'FontSize',18, ...
	'Style','text', ...
	'String','');
e_solution = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[45 80 180 120], ...
	'HorizontalAlignment','left', ...
	'FontSize',12, ...
	'Style','text', ...
	'String','');
t_solordi = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[230 80 180 120], ...
	'HorizontalAlignment','left', ...
	'FontSize',12, ...
	'Style','text', ...
	'String','');
t_masol = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[230 216 180 24], ...
	'HorizontalAlignment','left', ...
	'FontSize',18, ...
	'Style','text', ...
	'String','Ma solution:');
	
t_inter1 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[45 266 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque1');
t_inter2 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[113 266 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque2');
t_inter3 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[181 266 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque3');
t_inter4 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[249 266 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque4');
t_inter5 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[317 266 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque5');
t_inter6 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[385 266 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque6');
t_plaque1 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[45 316 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque1');
t_plaque2 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[113 316 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque2');
t_plaque3 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[181 316 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque3');
t_plaque4 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[249 316 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque4');
t_plaque5 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[317 316 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque5');
t_plaque6 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[385 316 51 20], ...
	'FontSize',18, ...
	'Style','push', ...
	'callback','plaque', ...
	'Tag','plaque6');
	
b_fois = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[45 292 51 20], ...
	'FontSize',18, ...
	'string','*', ...
	'Style','push', ...
	'callback','opc=get(gco,''string'');', ...
	'Tag','fois');
b_plus = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[113 292 51 20], ...
	'FontSize',18, ...
	'string','+', ...
	'Style','push', ...
	'callback','opc=get(gco,''string'');', ...
	'Tag','plus');
b_moins = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[181 292 51 20], ...
	'FontSize',18, ...
	'string','-', ...
	'Style','push', ...
	'callback','opc=get(gco,''string'');', ...
	'Tag','moins');
b_div = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[249 292 51 20], ...
	'FontSize',18, ...
	'string','/', ...
	'Style','push', ...
	'callback','opc=get(gco,''string'');', ...
	'Tag','div');
b_nouveau = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'BackgroundColor',[0.733333 0.733333 0.733333], ...
	'Position',[45 23 65 32], ...
	'String','Nouveau', ...
	'Tag','nouveau', ...
	'callback','nouveau');
t_chiffre1 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[230 346 20 24], ...
	'HorizontalAlignment','right', ...
	'FontSize',18, ...
	'Style','text', ...
	'Tag','chiffre1');
t_chiffre2 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[250 346 20 24], ...
	'HorizontalAlignment','center', ...
	'FontSize',18, ...
	'Style','text', ...
	'Tag','chiffre2');
t_chiffre3 = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'Position',[267 346 20 24], ...
	'HorizontalAlignment','left', ...
	'FontSize',18, ...
	'Style','text', ...
	'Tag','chiffre3');
b_fermer = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'BackgroundColor',[0.733333 0.733333 0.733333], ...
	'Position',[371 23 65 32], ...
	'String','Fermer', ...
	'callback','close(gcf)', ...
	'Tag','fermer');
b_verif = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'BackgroundColor',[0.733333 0.733333 0.733333], ...
	'Position',[160 23 65 32], ...
	'String','Vérification', ...
	'callback','verif', ...
	'Tag','verif');
b_solution = uicontrol('Parent',jeu, ...
	'Units','points', ...
	'BackgroundColor',[0.733333 0.733333 0.733333], ...
	'Position',[270 23 65 32], ...
	'String','Solution', ...
	'callback','solDeb', ...
	'Tag','solution');
nouveau
