commit
c1e06056ae
492 changed files with 132254 additions and 0 deletions
@ -0,0 +1,102 @@ |
|||||
|
<?xml version = '1.0'?> |
||||
|
<kdevelop> |
||||
|
<general> |
||||
|
<author>Nicolas MASSÉ</author> |
||||
|
<email>nicolas27.masse@laposte.net</email> |
||||
|
<version>$VERSION$</version> |
||||
|
<projectmanagement>KDevCustomProject</projectmanagement> |
||||
|
<primarylanguage>C</primarylanguage> |
||||
|
<ignoreparts/> |
||||
|
</general> |
||||
|
<kdevcustomproject> |
||||
|
<run> |
||||
|
<mainprogram>Compilation</mainprogram> |
||||
|
<directoryradio>executable</directoryradio> |
||||
|
</run> |
||||
|
</kdevcustomproject> |
||||
|
<kdevdebugger> |
||||
|
<general> |
||||
|
<dbgshell/> |
||||
|
</general> |
||||
|
</kdevdebugger> |
||||
|
<kdevdoctreeview> |
||||
|
<ignoretocs> |
||||
|
<toc>ada</toc> |
||||
|
<toc>ada_bugs_gcc</toc> |
||||
|
<toc>bash</toc> |
||||
|
<toc>bash_bugs</toc> |
||||
|
<toc>clanlib</toc> |
||||
|
<toc>fortran_bugs_gcc</toc> |
||||
|
<toc>gnome1</toc> |
||||
|
<toc>gnustep</toc> |
||||
|
<toc>gtk</toc> |
||||
|
<toc>gtk_bugs</toc> |
||||
|
<toc>haskell</toc> |
||||
|
<toc>haskell_bugs_ghc</toc> |
||||
|
<toc>java_bugs_gcc</toc> |
||||
|
<toc>java_bugs_sun</toc> |
||||
|
<toc>kde2book</toc> |
||||
|
<toc>libstdc++</toc> |
||||
|
<toc>opengl</toc> |
||||
|
<toc>pascal_bugs_fp</toc> |
||||
|
<toc>php</toc> |
||||
|
<toc>php_bugs</toc> |
||||
|
<toc>perl</toc> |
||||
|
<toc>perl_bugs</toc> |
||||
|
<toc>python</toc> |
||||
|
<toc>python_bugs</toc> |
||||
|
<toc>qt-kdev3</toc> |
||||
|
<toc>ruby</toc> |
||||
|
<toc>ruby_bugs</toc> |
||||
|
<toc>sdl</toc> |
||||
|
<toc>stl</toc> |
||||
|
<toc>sw</toc> |
||||
|
<toc>w3c-dom-level2-html</toc> |
||||
|
<toc>w3c-svg</toc> |
||||
|
<toc>w3c-uaag10</toc> |
||||
|
<toc>wxwidgets_bugs</toc> |
||||
|
</ignoretocs> |
||||
|
<ignoreqt_xml> |
||||
|
<toc>Guide to the Qt Translation Tools</toc> |
||||
|
<toc>Qt Assistant Manual</toc> |
||||
|
<toc>Qt Designer Manual</toc> |
||||
|
<toc>Qt Reference Documentation</toc> |
||||
|
<toc>qmake User Guide</toc> |
||||
|
</ignoreqt_xml> |
||||
|
<ignoredoxygen> |
||||
|
<toc>KDE Libraries (Doxygen)</toc> |
||||
|
</ignoredoxygen> |
||||
|
</kdevdoctreeview> |
||||
|
<kdevfilecreate> |
||||
|
<filetypes/> |
||||
|
<useglobaltypes> |
||||
|
<type ext="c" /> |
||||
|
<type ext="h" /> |
||||
|
</useglobaltypes> |
||||
|
</kdevfilecreate> |
||||
|
<kdevcppsupport> |
||||
|
<references/> |
||||
|
<codecompletion> |
||||
|
<includeGlobalFunctions>true</includeGlobalFunctions> |
||||
|
<includeTypes>true</includeTypes> |
||||
|
<includeEnums>true</includeEnums> |
||||
|
<includeTypedefs>false</includeTypedefs> |
||||
|
<automaticCodeCompletion>true</automaticCodeCompletion> |
||||
|
<automaticArgumentsHint>true</automaticArgumentsHint> |
||||
|
<automaticHeaderCompletion>true</automaticHeaderCompletion> |
||||
|
<codeCompletionDelay>250</codeCompletionDelay> |
||||
|
<argumentsHintDelay>400</argumentsHintDelay> |
||||
|
<headerCompletionDelay>250</headerCompletionDelay> |
||||
|
</codecompletion> |
||||
|
</kdevcppsupport> |
||||
|
<kdevfileview> |
||||
|
<groups> |
||||
|
<hidenonprojectfiles>false</hidenonprojectfiles> |
||||
|
<hidenonlocation>false</hidenonlocation> |
||||
|
</groups> |
||||
|
<tree> |
||||
|
<hidepatterns>*.o,*.lo,CVS</hidepatterns> |
||||
|
<hidenonprojectfiles>false</hidenonprojectfiles> |
||||
|
</tree> |
||||
|
</kdevfileview> |
||||
|
</kdevelop> |
||||
@ -0,0 +1,9 @@ |
|||||
|
# KDevelop Custom Project File List |
||||
|
debug.c |
||||
|
generator.c |
||||
|
generator.h |
||||
|
Makefile |
||||
|
epc.h |
||||
|
exemples/while.pas |
||||
|
exemples/if.pas |
||||
|
README |
||||
@ -0,0 +1,77 @@ |
|||||
|
#
|
||||
|
# Makefile ENSICAEN 2006
|
||||
|
#
|
||||
|
# MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net>
|
||||
|
# LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net>
|
||||
|
#
|
||||
|
# ENSICAEN
|
||||
|
# 6 Boulevard Marechal Juin
|
||||
|
# F-14050 Caen Cedex
|
||||
|
#
|
||||
|
# Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre
|
||||
|
# reproduit, utilise ou modifie sans l'avis express de ses auteurs.
|
||||
|
#
|
||||
|
|
||||
|
#
|
||||
|
# Construit le programme EPC
|
||||
|
#
|
||||
|
|
||||
|
#
|
||||
|
# version: 05/04/2006
|
||||
|
#
|
||||
|
# done: -
|
||||
|
#
|
||||
|
# todo: -
|
||||
|
#
|
||||
|
|
||||
|
|
||||
|
CC = gcc |
||||
|
CFLAGS = -Wall -ggdb |
||||
|
LDFLAGS = |
||||
|
|
||||
|
LEX = lex |
||||
|
|
||||
|
# Le -v génère un fichier "parser.output" contenant des informations utiles.
|
||||
|
YACC = yacc |
||||
|
YACCFLAGS = -v |
||||
|
|
||||
|
TARGETS = debug epc epc-debug |
||||
|
|
||||
|
all: $(TARGETS) exemples |
||||
|
|
||||
|
exemples: |
||||
|
$(MAKE) -C $@ |
||||
|
|
||||
|
epc: lex.yy.o parser.tab.o main_parser.o generator.o |
||||
|
$(CC) -o $@ $(LDFLAGS) $^ |
||||
|
|
||||
|
epc-debug: lex-debug.yy.o parser.tab.o main_parser.o generator.o |
||||
|
$(CC) -o $@ $(LDFLAGS) $^ |
||||
|
|
||||
|
debug: lex.yy.o debug.o parser.tab.o generator.o |
||||
|
$(CC) -o $@ $(LDFLAGS) $^ |
||||
|
|
||||
|
lex.yy.o: parser.tab.h |
||||
|
|
||||
|
lex-debug.yy.o: lex.yy.c parser.tab.h |
||||
|
$(CC) $(CFLAGS) -DDEBUG -c -o $@ $< |
||||
|
|
||||
|
lex.yy.c: scanner.l |
||||
|
$(LEX) $< |
||||
|
|
||||
|
parser.tab.c: parser.y |
||||
|
$(YACC) $(YACCFLAGS) -d -b parser $< |
||||
|
|
||||
|
parser.tab.h: parser.y |
||||
|
$(YACC) $(YACCFLAGS) -d -b parser $< |
||||
|
|
||||
|
clean: |
||||
|
rm -f lex.yy.c parser.tab.c parser.tab.h parser.output *.o $(TARGETS) |
||||
|
make -C exemples $@ |
||||
|
|
||||
|
distclean: clean |
||||
|
rm -f *~ |
||||
|
make -C exemples $@ |
||||
|
|
||||
|
|
||||
|
.PHONY: distclean clean all exemples |
||||
@ -0,0 +1,61 @@ |
|||||
|
============================================================================= |
||||
|
README ENSICAEN 2006 |
||||
|
|
||||
|
MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
|
||||
|
ENSICAEN |
||||
|
6 Boulevard Marechal Juin |
||||
|
F-14050 Caen Cedex |
||||
|
|
||||
|
Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
============================================================================= |
||||
|
|
||||
|
|
||||
|
|
||||
|
Travail effectué : |
||||
|
----------------------------------------------------------- |
||||
|
- Analyse lexicale |
||||
|
- Analyse syntaxique |
||||
|
- Génération de code à 3 adresses |
||||
|
- Makefiles |
||||
|
- Correction de bug dans la fonction trim |
||||
|
- Ajout de 2 fonctions dans generator.[hc] |
||||
|
+ void init(struct t_code * s); |
||||
|
+ char * getType(char * id); |
||||
|
- Test du programme avec les examples |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
Reste à faire : |
||||
|
----------------------------------------------------------- |
||||
|
- Vérification de type |
||||
|
- Tests intensifs |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
Description des fichiers : |
||||
|
----------------------------------------------------------- |
||||
|
epc.h : déclarations communes à tous les fichiers |
||||
|
debug.c : programme de test, analyse lexicale seulement |
||||
|
main_parser.c : le main du compilateur |
||||
|
parser.y : fichier yacc |
||||
|
scanner.l : fichier lex |
||||
|
exemples/*.pas : fichiers exemples |
||||
|
generator.[ch] : fonctions utilitaires |
||||
|
README : ce fichier |
||||
|
Compilation.kdevelop : projet KDevelop |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
Fichiers générés : |
||||
|
----------------------------------------------------------- |
||||
|
epc : le compilateur |
||||
|
epc-debug : le compilateur, avec affichage de l'analyse lexicale |
||||
|
debug : programme de test, analyse lexicale seulement |
||||
|
exemples/*.c : exemples compilés |
||||
|
parser.output : généré par yacc, descriptif de la grammaire |
||||
@ -0,0 +1,39 @@ |
|||||
|
/**
|
||||
|
* #(@)debug.c ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/*
|
||||
|
* @version 05/04/2006 |
||||
|
* |
||||
|
* done: - |
||||
|
* |
||||
|
* todo: - |
||||
|
*/ |
||||
|
|
||||
|
#include <stdio.h> |
||||
|
|
||||
|
/* Header commun */ |
||||
|
#include "epc.h" |
||||
|
|
||||
|
/** Le nom du programme, indispensable pour l'édition des liens */ |
||||
|
char * progname = "test"; |
||||
|
|
||||
|
/**
|
||||
|
* Programme de test : analyse lexicalement l'entrée standard. |
||||
|
*/ |
||||
|
int main() { |
||||
|
for (;;) |
||||
|
yylex(); |
||||
|
|
||||
|
} |
||||
|
|
||||
@ -0,0 +1,54 @@ |
|||||
|
/**
|
||||
|
* #(@)epc.h ENSICAEN 2006 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/*
|
||||
|
* Contient la déclaration des variables partagées entre les différents |
||||
|
* fichiers. |
||||
|
* |
||||
|
* @version 05/04/2006 |
||||
|
* |
||||
|
* done: - |
||||
|
* |
||||
|
* todo: - |
||||
|
*/ |
||||
|
|
||||
|
#ifndef EPC_H |
||||
|
#define EPC_H |
||||
|
|
||||
|
/* Pour FILE* */ |
||||
|
#include <stdio.h> |
||||
|
|
||||
|
/** Le nom du programme, défini dans le fichier parser.y */ |
||||
|
extern char* progname; |
||||
|
|
||||
|
/** L'analyseur syntaxique, fonction définie par lex */ |
||||
|
extern int yylex(void); |
||||
|
|
||||
|
/** Le flux d'entrée utilisée par l'analyseur syntaxique */ |
||||
|
extern FILE *yyin; |
||||
|
|
||||
|
/**
|
||||
|
* Analyseur syntaxique, fonction définie par yacc |
||||
|
* dans le fichier parser.tab.c |
||||
|
*/ |
||||
|
extern int yyparse(void); |
||||
|
|
||||
|
/** Définie dans le fichier scanner.l */ |
||||
|
extern int line_no; |
||||
|
|
||||
|
/** Définie par lex */ |
||||
|
extern char * yytext; |
||||
|
|
||||
|
|
||||
|
#endif /* EPC_H */ |
||||
@ -0,0 +1,49 @@ |
|||||
|
#
|
||||
|
# Makefile ENSICAEN 2006
|
||||
|
#
|
||||
|
# MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net>
|
||||
|
# LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net>
|
||||
|
#
|
||||
|
# ENSICAEN
|
||||
|
# 6 Boulevard Marechal Juin
|
||||
|
# F-14050 Caen Cedex
|
||||
|
#
|
||||
|
# Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre
|
||||
|
# reproduit, utilise ou modifie sans l'avis express de ses auteurs.
|
||||
|
#
|
||||
|
|
||||
|
#
|
||||
|
# Construit les exemples
|
||||
|
#
|
||||
|
|
||||
|
#
|
||||
|
# version: 05/04/2006
|
||||
|
#
|
||||
|
# done: -
|
||||
|
#
|
||||
|
# todo: -
|
||||
|
#
|
||||
|
|
||||
|
|
||||
|
CC = gcc |
||||
|
CFLAGS = -Wall |
||||
|
LDFLAGS = -lm |
||||
|
|
||||
|
EPC = ../epc |
||||
|
|
||||
|
TARGETS = if while micropascal |
||||
|
|
||||
|
all: $(TARGETS) |
||||
|
|
||||
|
$(TARGETS): % : %.pas $(EPC) |
||||
|
$(EPC) $< >$@.c |
||||
|
$(CC) $(CFLAGS) $(LDFLAGS) $@.c -o $@ |
||||
|
|
||||
|
clean: |
||||
|
rm -f *.c $(TARGETS) |
||||
|
|
||||
|
distclean: clean |
||||
|
rm -f *~ |
||||
|
|
||||
|
|
||||
|
.PHONY: distclean clean all |
||||
@ -0,0 +1,10 @@ |
|||||
|
program femto; |
||||
|
var var1 : integer; |
||||
|
begin |
||||
|
var1 := 10; |
||||
|
while (var1 * 2) > 0 do |
||||
|
begin |
||||
|
var1 := var1 - 1; |
||||
|
printf('%d\n', var1); |
||||
|
end; |
||||
|
end. |
||||
@ -0,0 +1,18 @@ |
|||||
|
program toto; |
||||
|
var i,j,k : integer; |
||||
|
|
||||
|
begin |
||||
|
|
||||
|
for i:=2 to 7 step 2 do |
||||
|
begin |
||||
|
writeln('i = ',i); |
||||
|
for j:=0 to 3 do |
||||
|
begin |
||||
|
writeln(' j = ',j); |
||||
|
for k:=5 downto 3 do |
||||
|
begin |
||||
|
writeln(' k = ',k); |
||||
|
end; |
||||
|
end; |
||||
|
end; |
||||
|
end. |
||||
@ -0,0 +1,12 @@ |
|||||
|
program if1; |
||||
|
var var1 : integer; |
||||
|
begin |
||||
|
var1 := 10; |
||||
|
|
||||
|
if (var1 * 2) > 0 then |
||||
|
printf('(var1 * 2) > 0\n'); |
||||
|
|
||||
|
if (var1 + 2 ) < 0 then |
||||
|
printf('(var1 + 2 ) < 0\n'); |
||||
|
end. |
||||
|
|
||||
@ -0,0 +1,17 @@ |
|||||
|
program toto; |
||||
|
var i : integer; |
||||
|
k,variablelongue : integer; |
||||
|
begin |
||||
|
i:=20; |
||||
|
variablelongue:=-10; |
||||
|
k:=i+2*3+4; |
||||
|
variablelongue:=pow(2,3); |
||||
|
if (NOT (1>2)) then i:=20; |
||||
|
|
||||
|
while (i> 10) do |
||||
|
begin |
||||
|
printf('i = %d\n', i+3); |
||||
|
if (i=2) then puts('i=2'); |
||||
|
i:=i-1; |
||||
|
end; |
||||
|
end. |
||||
@ -0,0 +1,124 @@ |
|||||
|
program testoffset; |
||||
|
|
||||
|
const |
||||
|
MAX = 100; |
||||
|
type |
||||
|
complex = record |
||||
|
re,im : integer; |
||||
|
end; |
||||
|
pile = array [0..10] of complex; |
||||
|
pile_int = array [0..10] of integer; |
||||
|
complexpile = record |
||||
|
p : array [0..2] of record |
||||
|
re,im : integer ; |
||||
|
end; |
||||
|
sommet : integer; |
||||
|
end; |
||||
|
|
||||
|
const |
||||
|
TOOOOOO = 100; |
||||
|
var |
||||
|
test1 : complex; |
||||
|
i : integer; |
||||
|
mapile : complexpile; |
||||
|
mapile2 : complexpile; |
||||
|
test : array [0..2] of integer; |
||||
|
test2 : array [0..2] of complex; |
||||
|
ok : boolean; |
||||
|
c : char; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
function fucnspeciale (idd : integer ):integer; |
||||
|
const MAX = 3; |
||||
|
var ddddeedede : integer; |
||||
|
begin |
||||
|
write (MAX); |
||||
|
idd:=45; |
||||
|
idd:=4; |
||||
|
end; |
||||
|
|
||||
|
procedure totii (idd :integer ); |
||||
|
const MAX = 4; |
||||
|
var ddddededede : integer; |
||||
|
begin |
||||
|
idd:=45; |
||||
|
write ('tot'); |
||||
|
end; |
||||
|
|
||||
|
procedure totii2 (idd :boolean ); |
||||
|
const MAX = 5; |
||||
|
var ddddededede : integer; |
||||
|
begin |
||||
|
idd:=true; |
||||
|
write ('tot'); |
||||
|
end; |
||||
|
|
||||
|
procedure totii3 (idd :boolean ); |
||||
|
const MAX = 6; |
||||
|
var ddddededede : integer; |
||||
|
begin |
||||
|
idd:=true; |
||||
|
write ('tot'); |
||||
|
end; |
||||
|
|
||||
|
procedure totii4 (idd :boolean ); |
||||
|
const MAX = 7; |
||||
|
var ddddededede : integer; |
||||
|
begin |
||||
|
idd:=true; |
||||
|
write ('tot'); |
||||
|
end; |
||||
|
|
||||
|
function fucnspeciale2 (idd :integer ):integer; |
||||
|
const MAX = 8; |
||||
|
var ddddeedede: integer; |
||||
|
begin |
||||
|
write ('tot'); |
||||
|
ddddeedede:=45; |
||||
|
idd:=4; |
||||
|
end; |
||||
|
|
||||
|
function specialtest (c : char ,b:boolean,i:integer):integer; |
||||
|
const MAX =9; |
||||
|
begin |
||||
|
i:=4; |
||||
|
specialtest:=4; |
||||
|
end; |
||||
|
|
||||
|
begin |
||||
|
totii2(true); |
||||
|
i:=10+fucnspeciale(i)+specialtest('t',false,1+5+8-8); |
||||
|
i:=10+fucnspeciale(i)+specialtest(c,ok,i); |
||||
|
test1.im:=4; |
||||
|
i:=10; |
||||
|
mapile.sommet := 0; |
||||
|
mapile2.sommet := 0; |
||||
|
mapile.p[2].re := 10; |
||||
|
test[5]:=MAX+5+i; |
||||
|
ok := true; |
||||
|
c := 't'; |
||||
|
writeln(ok); |
||||
|
read(ok, test2[1].re,c); |
||||
|
writeln(ok); |
||||
|
writeln(test2[1].re); |
||||
|
writeln (i); |
||||
|
|
||||
|
|
||||
|
writeln(1+5+8+8+7); |
||||
|
while true = ok do |
||||
|
begin |
||||
|
if i = 15 then |
||||
|
ok:=false; |
||||
|
writeln (i); |
||||
|
i:=i+1; |
||||
|
end; |
||||
|
c:='z'; |
||||
|
if c <> 't' then |
||||
|
writeln(ok); |
||||
|
|
||||
|
if 1+i=5+5+1 then |
||||
|
writeln(ok); |
||||
|
mapile.p[0].re :=3; |
||||
|
end. |
||||
@ -0,0 +1,38 @@ |
|||||
|
program tabmulti; |
||||
|
|
||||
|
var |
||||
|
test2 : array [2..4,3,4,5] of integer; |
||||
|
test : array [4,6,7] of integer; |
||||
|
i,j,k,l : integer; |
||||
|
|
||||
|
begin |
||||
|
test2[3,2,3,4]:=4; |
||||
|
i:=1; |
||||
|
j:=1; |
||||
|
k:=1; |
||||
|
l:=7; |
||||
|
{ for i:= 0 to 2 do } |
||||
|
{ begin } |
||||
|
{ for j:=0 to 3 do } |
||||
|
{ begin } |
||||
|
for k:=0 to 5 do |
||||
|
begin |
||||
|
write('k = '); |
||||
|
writeln (k); |
||||
|
for l:=0 to 6 do |
||||
|
begin |
||||
|
{ write('i = '); } |
||||
|
{ write (i); } |
||||
|
{ write(' j = '); } |
||||
|
{ write (j); } |
||||
|
write(' l = '); |
||||
|
writeln (l); |
||||
|
test[j,k,l] := l; |
||||
|
{ writeln(test[j,k,l]); } |
||||
|
end; |
||||
|
end; |
||||
|
{ end; } |
||||
|
{ end; } |
||||
|
test[3,5,6]:=4; |
||||
|
writeln( test[3,5,6]); |
||||
|
end. |
||||
@ -0,0 +1,10 @@ |
|||||
|
program while1; |
||||
|
var var1 : integer; |
||||
|
begin |
||||
|
var1 := 10; |
||||
|
while (var1 * 2) > 0 do |
||||
|
begin |
||||
|
var1 := var1 - 1; |
||||
|
printf('%d\n', var1); |
||||
|
end; |
||||
|
end. |
||||
@ -0,0 +1,169 @@ |
|||||
|
/** -*- c-basic-offset: 3 -*-
|
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* @author Regis Clouard |
||||
|
* |
||||
|
* @version 2006-03-06 |
||||
|
*/ |
||||
|
|
||||
|
#include <stdio.h> |
||||
|
#include <stdlib.h> |
||||
|
#include <string.h> |
||||
|
#include <stdarg.h> |
||||
|
#include "generator.h" |
||||
|
|
||||
|
/**
|
||||
|
* @file generator.c |
||||
|
* |
||||
|
* Theses functions do not care about memory management. |
||||
|
* @todo Manage memory. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Init the parser's union. |
||||
|
*/ |
||||
|
void init(struct t_code * s) { |
||||
|
s->after = ""; |
||||
|
s->before = ""; |
||||
|
s->code = ""; |
||||
|
s->place = ""; |
||||
|
s->type = ""; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Does not create new string. |
||||
|
*/ |
||||
|
char *trim( char *s ) { |
||||
|
// Bug : s[strlen(s)-2]='\0';
|
||||
|
s[strlen(s)-1]='\0'; |
||||
|
return s+1; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Creates a new string. |
||||
|
*/ |
||||
|
char *prod( const char *s ) { |
||||
|
if (s!=NULL && (strlen(s) > 0)) { |
||||
|
char* ns=(char*)malloc((strlen(s)+6)*sizeof(char)); |
||||
|
strcpy(ns," "); |
||||
|
strcat(ns,s); |
||||
|
strcat(ns,";\n"); |
||||
|
return ns; |
||||
|
} else { |
||||
|
return strdup(""); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* The current temporary counter. */ |
||||
|
static int _tempCounter=0; |
||||
|
|
||||
|
static struct s_table *_symbolTable=NULL; |
||||
|
|
||||
|
/**
|
||||
|
* Creates a new string that can be free. |
||||
|
*/ |
||||
|
char *newTemp( char * type) { |
||||
|
char *_name=(char *)malloc(7*sizeof(char)); |
||||
|
|
||||
|
sprintf(_name,"__t%03d",_tempCounter++); |
||||
|
addType(_name,type); |
||||
|
return _name; |
||||
|
} |
||||
|
|
||||
|
/* Current number of label. */ |
||||
|
static int _label=0; |
||||
|
|
||||
|
/**
|
||||
|
* Creates a new string that can be free. |
||||
|
*/ |
||||
|
char *newLabel( ) { |
||||
|
char *_name=(char *)malloc(5*sizeof(char)); |
||||
|
|
||||
|
sprintf(_name,"__L%03d",_label++); |
||||
|
return _name; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Creates a new string. |
||||
|
*/ |
||||
|
char *concat( const char *item, ... ) { |
||||
|
//const char *p;
|
||||
|
va_list argp; |
||||
|
//int i;
|
||||
|
char *s; |
||||
|
int size=strlen(item)+1; |
||||
|
char *statement=(char *)malloc(size*sizeof(char)); |
||||
|
|
||||
|
va_start(argp, item); |
||||
|
strcpy(statement,item); |
||||
|
while ((s = va_arg(argp, char *))!= NULL) { |
||||
|
statement=realloc(statement,size+strlen(s)); |
||||
|
statement[size-1]='\0'; |
||||
|
strcat(statement,s); |
||||
|
size+=strlen(s); |
||||
|
} |
||||
|
|
||||
|
va_end(argp); |
||||
|
statement[size-1]='\0'; |
||||
|
return statement; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Allocates a new entry in the symbol table, but |
||||
|
* the structure field are already allocated. |
||||
|
* @param a name for the identifier. |
||||
|
* @param type a type name (int, float, void ...). |
||||
|
*/ |
||||
|
void addType(char *identifier, char* type) { |
||||
|
struct s_table *ns= (struct s_table *)(malloc(sizeof(struct s_table))); |
||||
|
|
||||
|
strcpy(ns->name,identifier); |
||||
|
strcpy(ns->type,type); |
||||
|
ns->next=_symbolTable; |
||||
|
_symbolTable=ns; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le type d'un symbole |
||||
|
*/ |
||||
|
char * getType(char * id) { |
||||
|
struct s_table * se = _symbolTable; |
||||
|
while (se != NULL) { |
||||
|
if (strcmp(se->name, id) == 0) { |
||||
|
return se->type; |
||||
|
} |
||||
|
|
||||
|
se = se->next; |
||||
|
} |
||||
|
|
||||
|
// type par defaut
|
||||
|
return "void"; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Goes through the symbol table and builds |
||||
|
* the convenient C statement liek: type variable; |
||||
|
* One line per variable. |
||||
|
*/ |
||||
|
char *genDeclarationVars( ) { |
||||
|
char *s,*s1; |
||||
|
struct s_table *t=_symbolTable; |
||||
|
|
||||
|
s=NULL; |
||||
|
while ( t!= NULL) { |
||||
|
s1=s; |
||||
|
s=concat(prod(concat(t->type," ",t->name,NULL)),s1,NULL); |
||||
|
if (s1) free(s1); |
||||
|
t=t->next; |
||||
|
} |
||||
|
return s; |
||||
|
} |
||||
@ -0,0 +1,130 @@ |
|||||
|
/** -*- c-basic-offset: 3 -*-
|
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
#ifndef GENERATOR_H |
||||
|
#define GENERATOR_H |
||||
|
|
||||
|
#include "parser.tab.h" |
||||
|
|
||||
|
/**
|
||||
|
* @author Regis Clouard |
||||
|
* @author Nicolas Massé |
||||
|
* @author Thomas Limin |
||||
|
* |
||||
|
* @version 2006-03-06 |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* @file generator.h |
||||
|
* This file contains functions for managing |
||||
|
* symbol table and intermediate code. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* The symbol table. |
||||
|
*/ |
||||
|
struct s_table { |
||||
|
char name[255]; /* the name of the symbol */ |
||||
|
char type[255]; /* The C type of symbol : int, float, void. */ |
||||
|
struct s_table *next; /* The next symbol. */ |
||||
|
}; |
||||
|
|
||||
|
extern struct s_table *_symbolTable; |
||||
|
|
||||
|
/**
|
||||
|
* Initialise une structure de donnees du parseur. |
||||
|
*/ |
||||
|
void init(struct t_code * s); |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le type d'un symbole. |
||||
|
*/ |
||||
|
char * getType(char * id); |
||||
|
|
||||
|
/**
|
||||
|
* Creates a new entry in the symbol table |
||||
|
* for the given identifier with the specified type. |
||||
|
* Available types are those of the C language. |
||||
|
* For example, the following call adds the integer |
||||
|
* variable 'i' in the symbol table: |
||||
|
* <pre> |
||||
|
* addType("i","int"); |
||||
|
* </pre> |
||||
|
* @param the name of the identifier. |
||||
|
* @param type the type name (int, float, void ...). |
||||
|
*/ |
||||
|
void addType( char *identifier, char *type ) ; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the code for the declaration |
||||
|
* of all the variables in the symbol table. |
||||
|
* @return the code. |
||||
|
*/ |
||||
|
char* genDeclarationVars(); |
||||
|
|
||||
|
/**
|
||||
|
* Creates a new tempory variable name with the |
||||
|
* specified type. Available types are those |
||||
|
* of the C language: int, float, etc. For |
||||
|
* example the following call creates a new |
||||
|
* integer variable: |
||||
|
* <pre> |
||||
|
* char * variable=newTemp("int"); |
||||
|
* </pre> |
||||
|
* The variable name template looks like __txxx where |
||||
|
* xxx is a serial integer number that begins with 1. |
||||
|
* For example, the second call to newTemp returns: __t002 |
||||
|
* Also, adds the variable in the symbol table. |
||||
|
* |
||||
|
* @param type the type of the temporary variable. |
||||
|
* @return a new variable name. |
||||
|
*/ |
||||
|
char* newTemp( char *type ); |
||||
|
|
||||
|
/**
|
||||
|
* Creates a new label name. |
||||
|
* The label name takes the form of __Lxxxx |
||||
|
* where xxxx is an integer. For example, |
||||
|
* the second call to newLabel() return __L002 |
||||
|
* @return the string with the label name. |
||||
|
*/ |
||||
|
char *newLabel( ) ; |
||||
|
|
||||
|
/**
|
||||
|
* Catenates the given strings into one single string. |
||||
|
* The result string is dynamically allocated. So a free |
||||
|
* is necessary for destruction. |
||||
|
* @param items the list of input strings. |
||||
|
* @return the new statement. |
||||
|
*/ |
||||
|
char *concat( const char *item, ... ); |
||||
|
|
||||
|
/**
|
||||
|
* Returns the given string without the first and |
||||
|
* the last character. For example this is convenient |
||||
|
* for getting text from Pascal string: |
||||
|
* <pre> |
||||
|
* trim("'this a text'"); -> returns "this a text" |
||||
|
* </pre> |
||||
|
* @param s the string to process. |
||||
|
* @return the string modified. |
||||
|
*/ |
||||
|
char *trim( char *s ); |
||||
|
|
||||
|
/**
|
||||
|
* Builds a C statement with |
||||
|
* the given code. |
||||
|
* Adds semicolon and indents each line. |
||||
|
* @param s the given code. |
||||
|
* @return the C statement. |
||||
|
*/ |
||||
|
char *prod( const char *s ) ; |
||||
|
|
||||
|
#endif /* GENERATOR_H */ |
||||
@ -0,0 +1,59 @@ |
|||||
|
/**
|
||||
|
* #(@)main_parser.c ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Executes the parser and the semantic analyzer. |
||||
|
* Generates the intermediate code to standard output. |
||||
|
* The compiler accepts only one Pascal file. |
||||
|
*/ |
||||
|
|
||||
|
#include "parser.tab.h" |
||||
|
#include "epc.h" |
||||
|
|
||||
|
#include <string.h> |
||||
|
#include <stdlib.h> |
||||
|
|
||||
|
int main( int argc, char *argv[] ) { |
||||
|
if (argc == 1) { |
||||
|
fprintf(stderr,"%s: no input files\n",argv[0]); |
||||
|
exit(1); |
||||
|
} |
||||
|
|
||||
|
if (strcmp(argv[1],"-h") == 0) { |
||||
|
fprintf(stderr,"Usage: %s [options] file\n",argv[0]); |
||||
|
fputs("Options:",stderr); |
||||
|
fputs(" -h Display this information",stderr); |
||||
|
exit(0); |
||||
|
} |
||||
|
|
||||
|
yyin=fopen(argv[1], "r"); /* Open the input for the parser. */ |
||||
|
|
||||
|
/* @todo: !! Add a function to get only the name of the */ |
||||
|
/* file without the path. */ |
||||
|
progname=argv[1]; |
||||
|
|
||||
|
if (!yyin) { /* Cannot open input file. */ |
||||
|
fprintf(stderr,"%s: %s: No such file or directory\n",argv[0],argv[1]); |
||||
|
fprintf(stderr,"%s: no input file\n",argv[0]); |
||||
|
return 1; |
||||
|
} |
||||
|
|
||||
|
if (yyparse()) { |
||||
|
fprintf(stderr,"%s: %s: compilation failed\n",argv[0],argv[1]); |
||||
|
return 1; |
||||
|
} |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,428 @@ |
|||||
|
/** |
||||
|
* #(@)parser.y ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
* @version 05/04/2006 |
||||
|
* |
||||
|
* done: - |
||||
|
* |
||||
|
* todo: - |
||||
|
*/ |
||||
|
|
||||
|
/** |
||||
|
* @file parser.y |
||||
|
* |
||||
|
* Part of the Pascal grammar in Yacc format, based originally on BNF. |
||||
|
* The grammar has been massaged somewhat to make it LALR, and limited |
||||
|
* to integer type, and if and while control structure. |
||||
|
*/ |
||||
|
|
||||
|
%{ |
||||
|
#include <stdio.h> |
||||
|
#include <string.h> |
||||
|
#include <stdlib.h> |
||||
|
|
||||
|
/* Fonctions utilitaires */ |
||||
|
#include "generator.h" |
||||
|
|
||||
|
/* Header commun */ |
||||
|
#include "epc.h" |
||||
|
|
||||
|
/* voir le corps de la méthode ci-dessous */ |
||||
|
int yyerror(char * s); |
||||
|
|
||||
|
/** Le nom du programme, utilisée par yacc */ |
||||
|
char * progname; |
||||
|
%} |
||||
|
|
||||
|
/** |
||||
|
* The list of attributes associated to each terminal |
||||
|
* and non terminal of the grammar. |
||||
|
*/ |
||||
|
%union { |
||||
|
char strval[255]; /* The value of the token. */ |
||||
|
|
||||
|
/** |
||||
|
* This structure defines the convenient |
||||
|
* information for building the code. |
||||
|
*/ |
||||
|
struct t_code { |
||||
|
char* code; /* The string that contains the 3 address code */ |
||||
|
char* place; /* The name of the identifier or the temporary variable. */ |
||||
|
char* before; /* The name of the label before the code. */ |
||||
|
char* after; /* The name of the label after the code. */ |
||||
|
char* type; /* The name of the type (int, float, ...). */ |
||||
|
} code3a; |
||||
|
} |
||||
|
|
||||
|
/* Les jetons */ |
||||
|
%token AND ASSIGNMENT |
||||
|
%token COLON COMMA DO DOT END EQUAL |
||||
|
%token GE GT IF IN INTEGER LBRAC LE |
||||
|
%token LPAREN LT MINUS NOT NOTEQUAL OF OR |
||||
|
%token PBEGIN PLUS |
||||
|
%token PROGRAM |
||||
|
%token RBRAC RPAREN |
||||
|
%token SEMICOLON DIV MULT THEN |
||||
|
%token VAR WHILE |
||||
|
%token <strval> IDENTIFIER |
||||
|
%token <strval> REALNUMBER |
||||
|
%token <strval> INTNUMBER |
||||
|
%token <strval> CHARACTER_STRING |
||||
|
|
||||
|
/* Operator associativity. */ |
||||
|
%left PLUS MINUS |
||||
|
%left OR AND NOT |
||||
|
%right MULT DIV |
||||
|
|
||||
|
/* The axiom. */ |
||||
|
%start program |
||||
|
|
||||
|
/* Information de typage des non termimaux */ |
||||
|
%type <code3a> identifier number term type_denoter sign |
||||
|
%type <code3a> compound_statement statement_sequence procedure_statement |
||||
|
%type <code3a> simple_expression expression instruction |
||||
|
%type <code3a> actual_parameter_list relop variable_declaration |
||||
|
%type <code3a> program_heading block statement_part |
||||
|
%% |
||||
|
program: program_heading SEMICOLON block DOT |
||||
|
{ |
||||
|
puts("#include <stdio.h>"); |
||||
|
puts("#include <math.h>"); |
||||
|
puts($1.code); |
||||
|
puts($3.code); |
||||
|
} |
||||
|
; |
||||
|
|
||||
|
program_heading: PROGRAM identifier |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = concat("/* nom du programme : '", $2.place, "' */", NULL); |
||||
|
} |
||||
|
; |
||||
|
|
||||
|
block: variable_declaration_part statement_part |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = concat("int main(void) {\n", |
||||
|
$2.code, |
||||
|
prod("return 0"), |
||||
|
"}\n", NULL); |
||||
|
} |
||||
|
; |
||||
|
|
||||
|
statement_part: compound_statement |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = concat(" /* début des variables */\n", |
||||
|
genDeclarationVars(), |
||||
|
" /* fin des variables */\n\n", |
||||
|
$1.code, NULL); |
||||
|
} |
||||
|
; |
||||
|
|
||||
|
variable_declaration_part : VAR variable_declaration_list SEMICOLON |
||||
|
{ |
||||
|
} |
||||
|
| |
||||
|
{ |
||||
|
} |
||||
|
; |
||||
|
|
||||
|
variable_declaration_list : variable_declaration_list SEMICOLON variable_declaration |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
| variable_declaration |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
; |
||||
|
variable_declaration : identifier COLON type_denoter |
||||
|
{ |
||||
|
init(&$$); |
||||
|
addType($1.place, $3.type); |
||||
|
$$.type = $3.type; |
||||
|
} |
||||
|
| identifier COMMA variable_declaration |
||||
|
{ |
||||
|
init(&$$); |
||||
|
addType($1.place, $3.type); |
||||
|
$$.type = $3.type; |
||||
|
} |
||||
|
|
||||
|
; |
||||
|
type_denoter: INTEGER |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = "int"; |
||||
|
} |
||||
|
; |
||||
|
|
||||
|
compound_statement: PBEGIN statement_sequence SEMICOLON END |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = concat(" { /* début du bloc */\n", $2.code, " } /* fin du bloc */\n", NULL); |
||||
|
} |
||||
|
; |
||||
|
statement_sequence: instruction |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = $1.code; |
||||
|
} |
||||
|
| statement_sequence SEMICOLON instruction |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = concat($1.code, $3.code, NULL); |
||||
|
} |
||||
|
; |
||||
|
/* INSTRUCTION */ |
||||
|
instruction: identifier ASSIGNMENT expression /* S -> id:=E */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = concat($3.code, prod(concat($1.place , " = ", $3.place, NULL)), NULL); |
||||
|
} |
||||
|
| procedure_statement /* S->procedure(args) */ |
||||
|
{ |
||||
|
$$ = $1; // pass through |
||||
|
} |
||||
|
| compound_statement /* S -> BEGIN S END */ |
||||
|
{ |
||||
|
$$ = $1; // pass through |
||||
|
} |
||||
|
| IF expression THEN instruction /* S -> IF THEN */ |
||||
|
{ |
||||
|
$$.after = newLabel(); |
||||
|
$$.code = concat($2.code, |
||||
|
prod(concat("if (", $2.place, " == 0) goto ", $$.after, NULL)), |
||||
|
$4.code, |
||||
|
prod(concat($$.after, ":", NULL)), |
||||
|
NULL); |
||||
|
} |
||||
|
| WHILE expression DO instruction /* S-> WHILE DO */ |
||||
|
{ |
||||
|
$$.before = newLabel(); |
||||
|
$$.after = newLabel(); |
||||
|
$$.code = concat(prod(concat($$.before, ":", NULL)), |
||||
|
$2.code, |
||||
|
prod(concat("if (", $2.place, " == 0) goto ", $$.after, NULL)), |
||||
|
$4.code, |
||||
|
prod(concat("goto ", $$.before, NULL)), |
||||
|
prod(concat($$.after, ":", NULL)), |
||||
|
NULL); |
||||
|
} |
||||
|
; |
||||
|
/* PROCEDURE CALL */ |
||||
|
procedure_statement: identifier /* no actual parameter list */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = prod(concat($1.place, "()", NULL)); |
||||
|
$$.type = "void"; |
||||
|
} |
||||
|
| identifier LPAREN actual_parameter_list RPAREN /* with actual argument list */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = concat($3.code, prod(concat($1.place, "(", $3.place, ")", NULL)), NULL); |
||||
|
$$.type= "void"; |
||||
|
} |
||||
|
; |
||||
|
actual_parameter_list: expression |
||||
|
{ |
||||
|
$$ = $1; // pass through |
||||
|
} |
||||
|
| actual_parameter_list COMMA expression |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = concat($1.code, $3.code, NULL); |
||||
|
$$.place = concat($1.place, ", ", $3.place, NULL); |
||||
|
} |
||||
|
; |
||||
|
/* EXPRESSIONS */ |
||||
|
expression: simple_expression |
||||
|
{ |
||||
|
$$ = $1; // pass through |
||||
|
} |
||||
|
| simple_expression relop simple_expression |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = $1.type; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($1.code, $3.code, prod(concat($$.place, " = ", $1.place, " ", $2.code , " ", $3.place, NULL)), NULL); |
||||
|
} |
||||
|
; |
||||
|
simple_expression: term /* E -> T */ |
||||
|
{ |
||||
|
$$ = $1; // pass through |
||||
|
} |
||||
|
| sign term /* E-> +/- T */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = $2.type; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($2.code, |
||||
|
prod(concat($$.place, " = ", $1.code, " ", $2.place, NULL)), |
||||
|
NULL); |
||||
|
} |
||||
|
| NOT simple_expression /* E-> NOT E */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = $2.type; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($2.code, |
||||
|
prod(concat($$.place, " = ! ", $2.place, NULL)), |
||||
|
NULL); |
||||
|
|
||||
|
} |
||||
|
| simple_expression PLUS simple_expression /* E -> E + E */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = $1.type; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($1.code, $3.code, prod(concat($$.place, " = ", $1.place, " + ", $3.place, NULL)), NULL); |
||||
|
} |
||||
|
| simple_expression MINUS simple_expression /* E -> E - E */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = $1.type; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($1.code, $3.code, prod(concat($$.place, " = ", $1.place, " - ", $3.place, NULL)), NULL); |
||||
|
} |
||||
|
| simple_expression MULT simple_expression /* E -> E * E */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = $1.type; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($1.code, $3.code, prod(concat($$.place, " = ", $1.place, " * ", $3.place, NULL)), NULL); |
||||
|
} |
||||
|
| simple_expression DIV simple_expression /* E -> E / E */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = $1.type; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($1.code, $3.code, prod(concat($$.place, " = ", $1.place, " / ", $3.place, NULL)), NULL); |
||||
|
} |
||||
|
| simple_expression AND simple_expression /* E -> E AND E */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = $1.type; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($1.code, $3.code, prod(concat($$.place, " = ", $1.place, " && ", $3.place, NULL)), NULL); |
||||
|
} |
||||
|
| simple_expression OR simple_expression /* E -> E OR E */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = $1.type; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($1.code, $3.code, prod(concat($$.place, " = ", $1.place, " || ", $3.place, NULL)), NULL); |
||||
|
} |
||||
|
| LPAREN expression RPAREN /* E -> (E) */ |
||||
|
{ |
||||
|
$$ = $2; // pass through |
||||
|
} |
||||
|
; |
||||
|
term: identifier |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.place = $1.place; |
||||
|
$$.type = $1.type; |
||||
|
} |
||||
|
| identifier LPAREN actual_parameter_list RPAREN /* Function call */ |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = "int"; // TODO type checking |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = concat($3.code, |
||||
|
prod(concat($$.place, " = ", $1.place, "(", $3.place, ")", NULL)), |
||||
|
NULL); |
||||
|
} |
||||
|
| number |
||||
|
{ |
||||
|
$$ = $1; // pass through |
||||
|
} |
||||
|
| CHARACTER_STRING |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.type = "char *"; |
||||
|
$$.place = newTemp($$.type); |
||||
|
$$.code = prod(concat($$.place, " = ", concat("\"", trim($1), "\"", NULL), NULL)); |
||||
|
} |
||||
|
; |
||||
|
identifier: IDENTIFIER |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.place = strdup($1); |
||||
|
$$.type = getType($1); |
||||
|
} |
||||
|
; |
||||
|
number: INTNUMBER |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.place = strdup($1); |
||||
|
$$.type = "int"; |
||||
|
} |
||||
|
; |
||||
|
sign: PLUS |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = "+"; |
||||
|
} |
||||
|
| MINUS |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = "-"; |
||||
|
} |
||||
|
; |
||||
|
relop: EQUAL |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = "=="; |
||||
|
} |
||||
|
| NOTEQUAL |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = "!="; |
||||
|
} |
||||
|
| LT |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = "<"; |
||||
|
} |
||||
|
| GT |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = ">"; |
||||
|
} |
||||
|
| LE |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = "<="; |
||||
|
} |
||||
|
| GE |
||||
|
{ |
||||
|
init(&$$); |
||||
|
$$.code = ">="; |
||||
|
} |
||||
|
; |
||||
|
%% |
||||
|
|
||||
|
/** |
||||
|
* Provides a yyerror routine which simply reports error line. |
||||
|
* It is called when the parser finds something not covered by any rule. |
||||
|
* |
||||
|
* @param s the error message to print. |
||||
|
*/ |
||||
|
int yyerror(char * s) { |
||||
|
fprintf(stderr, "%s:%d: %s: at or before '%s'\n", progname, line_no, s, yytext); |
||||
|
return 0; |
||||
|
} |
||||
@ -0,0 +1,163 @@ |
|||||
|
/** |
||||
|
* #(@)scanner.l ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
* @version 05/04/2006 |
||||
|
* |
||||
|
* done: - |
||||
|
* |
||||
|
* todo: - |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
%{ |
||||
|
#include <stdio.h> |
||||
|
#include <string.h> |
||||
|
|
||||
|
/* Header généré par yacc */ |
||||
|
#include "parser.tab.h" |
||||
|
|
||||
|
/* Header commun */ |
||||
|
#include "epc.h" |
||||
|
|
||||
|
/** |
||||
|
* Affiche le jeton sur la sortie standard et le retourne. |
||||
|
* |
||||
|
* @param x le jeton |
||||
|
* @return le jeton |
||||
|
*/ |
||||
|
#ifdef DEBUG |
||||
|
#define A(x) {printf("Trouve: %s = \"%s\"\n", #x, yytext); return x;} |
||||
|
#else |
||||
|
#define A(x) {return x;} |
||||
|
#endif |
||||
|
|
||||
|
/** Le numéro de la ligne courante */ |
||||
|
int line_no = 1; |
||||
|
|
||||
|
/* Termine un commentaire ? */ |
||||
|
void commenteof(); |
||||
|
|
||||
|
%} |
||||
|
|
||||
|
ID [a-zA-Z][a-zA-Z0-9_]* |
||||
|
INT [0-9]+ |
||||
|
REAL [0-9]*\.[0-9]+ |
||||
|
A [aA] |
||||
|
B [bB] |
||||
|
C [cC] |
||||
|
D [dD] |
||||
|
E [eE] |
||||
|
F [fF] |
||||
|
G [gG] |
||||
|
H [hH] |
||||
|
I [iI] |
||||
|
J [jJ] |
||||
|
K [kK] |
||||
|
L [lL] |
||||
|
M [mM] |
||||
|
N [nN] |
||||
|
O [oO] |
||||
|
P [pP] |
||||
|
Q [qQ] |
||||
|
R [rR] |
||||
|
S [sS] |
||||
|
T [tT] |
||||
|
U [uU] |
||||
|
V [vV] |
||||
|
W [wW] |
||||
|
X [xX] |
||||
|
Y [yY] |
||||
|
Z [zZ] |
||||
|
|
||||
|
|
||||
|
%% |
||||
|
|
||||
|
"(*" | |
||||
|
"{" { int c; |
||||
|
while ((c = input())) { |
||||
|
if (c == '}') |
||||
|
break; |
||||
|
else if (c == '*') { |
||||
|
if ((c = input()) == ')') |
||||
|
break; |
||||
|
else |
||||
|
unput (c); |
||||
|
} else if (c == '\n') |
||||
|
line_no++; |
||||
|
else if (c == 0) |
||||
|
commenteof(); |
||||
|
} |
||||
|
} |
||||
|
{A}{N}{D} {A(AND)} |
||||
|
{N}{O}{T} {A(NOT)} |
||||
|
{O}{R} {A(OR)} |
||||
|
{D}{O} {A(DO)} |
||||
|
{I}{F} {A(IF)} |
||||
|
{I}{N} {A(IN)} |
||||
|
{E}{N}{D} {A(END)} |
||||
|
{O}{F} {A(OF)} |
||||
|
{B}{E}{G}{I}{N} {A(PBEGIN)} |
||||
|
{P}{R}{O}{G}{R}{A}{M} {A(PROGRAM)} |
||||
|
{T}{H}{E}{N} {A(THEN)} |
||||
|
{V}{A}{R} {A(VAR)} |
||||
|
{W}{H}{I}{L}{E} {A(WHILE)} |
||||
|
{I}{N}{T}{E}{G}{E}{R} {A(INTEGER)} |
||||
|
":=" {A(ASSIGNMENT)} |
||||
|
'[^']*' {strcpy(yylval.strval, yytext); A(CHARACTER_STRING)} |
||||
|
":" {A(COLON)} |
||||
|
";" {A(SEMICOLON)} |
||||
|
"," {A(COMMA)} |
||||
|
"." {A(DOT)} |
||||
|
"=" {A(EQUAL)} |
||||
|
">=" {A(GE)} |
||||
|
">" {A(GT)} |
||||
|
"<" {A(LT)} |
||||
|
"<>" {A(NOTEQUAL)} |
||||
|
"<=" {A(LE)} |
||||
|
"[" {A(LBRAC)} |
||||
|
"]" {A(RBRAC)} |
||||
|
"(" {A(LPAREN)} |
||||
|
")" {A(RPAREN)} |
||||
|
"-" {A(MINUS)} |
||||
|
"+" {A(PLUS)} |
||||
|
"/" {A(DIV)} |
||||
|
"*" {A(MULT)} |
||||
|
{INT} {strcpy(yylval.strval, yytext); A(INTNUMBER)} |
||||
|
{REAL} {strcpy(yylval.strval, yytext); A(REALNUMBER)} |
||||
|
{ID} {strcpy(yylval.strval, yytext); A(IDENTIFIER)} |
||||
|
[ \t\f] ; |
||||
|
\n line_no++; |
||||
|
. fprintf (stderr,"%s:%d: error: '%c' (%d): illegal character\n", progname,line_no,yytext[0], yytext[0]); |
||||
|
%% |
||||
|
|
||||
|
/** |
||||
|
* Prints error message in case of bad comment pattern. |
||||
|
*/ |
||||
|
void commenteof() { |
||||
|
fprintf (stderr, "%s:%d:error: unexpected EOF inside comment at line\n", progname, line_no); |
||||
|
exit (1); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* If the application requires yylex to continue processing |
||||
|
* with another source of input, returns TRUE. |
||||
|
* |
||||
|
* @return always TRUE. |
||||
|
*/ |
||||
|
int yywrap () { |
||||
|
return 1; |
||||
|
} |
||||
|
|
||||
|
|
||||
@ -0,0 +1,96 @@ |
|||||
|
/* |
||||
|
* #(@)AccountImpl.java ENSICAEN 2005 |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
package Bank; |
||||
|
|
||||
|
import BankManagement.*; |
||||
|
|
||||
|
import org.omg.CosNaming.*; |
||||
|
import org.omg.CosNaming.NamingContextPackage.*; |
||||
|
import org.omg.CORBA.*; |
||||
|
import org.omg.PortableServer.*; |
||||
|
import org.omg.PortableServer.POA; |
||||
|
|
||||
|
import java.util.*; |
||||
|
|
||||
|
/** |
||||
|
* Un compte bancaire concret: le servant |
||||
|
*/ |
||||
|
class AccountImpl extends AccountPOA { |
||||
|
|
||||
|
/** |
||||
|
* Le solde du compte. |
||||
|
*/ |
||||
|
private int balance = 0; |
||||
|
|
||||
|
/** |
||||
|
* Le possesseur du compte. |
||||
|
*/ |
||||
|
private String username; |
||||
|
|
||||
|
/** |
||||
|
* La liste des operations. |
||||
|
*/ |
||||
|
private List<String> opList; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* Construit un nouveau compte bancaire. |
||||
|
*/ |
||||
|
public AccountImpl(String username) { |
||||
|
setUsername(username); |
||||
|
opList = new ArrayList<String>(); |
||||
|
} |
||||
|
|
||||
|
private void setUsername(String user) { |
||||
|
this.username = user; |
||||
|
} |
||||
|
|
||||
|
public String getUsername() { |
||||
|
return this.username; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Retourne le solde du compte. |
||||
|
*/ |
||||
|
public int balance() { |
||||
|
return balance; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Effectue un retrait. |
||||
|
*/ |
||||
|
public void withdraw(int amount) { |
||||
|
balance -= amount; |
||||
|
opList.add("withdraw[amount = " + amount + "]"); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Effectue un retrait. |
||||
|
*/ |
||||
|
public void deposit(int amount) { |
||||
|
balance += amount; |
||||
|
opList.add("deposit[amount = " + amount + "]"); |
||||
|
} |
||||
|
|
||||
|
public String operations() { |
||||
|
StringBuffer sb = new StringBuffer(); |
||||
|
|
||||
|
Iterator it = opList.iterator(); |
||||
|
while (it.hasNext()) { |
||||
|
sb.append(it.next()); |
||||
|
sb.append(Character.LINE_SEPARATOR); |
||||
|
} |
||||
|
|
||||
|
return sb.toString(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
@ -0,0 +1,195 @@ |
|||||
|
/* |
||||
|
* #(@)BankClient.java ENSICAEN 2005 |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
package Bank; |
||||
|
|
||||
|
import BankManagement.*; |
||||
|
|
||||
|
import java.io.*; |
||||
|
import java.util.*; |
||||
|
import org.omg.CosNaming.*; |
||||
|
import org.omg.CORBA.*; |
||||
|
|
||||
|
/** |
||||
|
* Le client qui permet d'accéder au serveur. |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* @version 0.0.1 |
||||
|
*/ |
||||
|
public class BankClient { |
||||
|
public static void main(String args[]) { |
||||
|
|
||||
|
String host = "localhost"; |
||||
|
String port = "1050"; |
||||
|
|
||||
|
if (args.length >= 1) { |
||||
|
port = args[0]; |
||||
|
} |
||||
|
|
||||
|
if (args.length >= 2) { |
||||
|
host = args[1]; |
||||
|
} |
||||
|
|
||||
|
displayHelp(); |
||||
|
|
||||
|
try { |
||||
|
// create and initialize the ORB
|
||||
|
ORB orb = ORB.init(new String[] {"-ORBInitialPort", host, "-ORBInitialPort", port }, null); |
||||
|
|
||||
|
// get the root naming context
|
||||
|
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); |
||||
|
NamingContext ncRef = NamingContextHelper.narrow(objRef); |
||||
|
|
||||
|
// resolve the Object Reference in Naming
|
||||
|
// make sure there are no spaces between ""
|
||||
|
NameComponent nc = new NameComponent("Bank", ""); |
||||
|
NameComponent path[] = {nc}; |
||||
|
Bank bankRef = BankHelper.narrow(ncRef.resolve(path)); |
||||
|
|
||||
|
|
||||
|
int accNum = -1; |
||||
|
int sessionId = -1; |
||||
|
String user = null; |
||||
|
String pass = null; |
||||
|
Account accRef = null; |
||||
|
|
||||
|
boolean quit = false; |
||||
|
|
||||
|
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); |
||||
|
|
||||
|
|
||||
|
while (!quit) { |
||||
|
StringTokenizer stk = new StringTokenizer(buff.readLine(), " \t"); |
||||
|
|
||||
|
try { |
||||
|
|
||||
|
while (!quit && stk.hasMoreTokens()) { |
||||
|
String token = stk.nextToken(); |
||||
|
|
||||
|
|
||||
|
if (token.equals("login")) { |
||||
|
System.out.print("[ LOGIN ] (void)"); |
||||
|
if (stk.hasMoreTokens()) { |
||||
|
user = stk.nextToken(); |
||||
|
System.out.println(" : login = " + user); |
||||
|
} else { |
||||
|
throw new Exception("Syntax error at '" + token + "'"); |
||||
|
} |
||||
|
} else if (token.equals("pass")) { |
||||
|
System.out.print("[ PASS ] (void)"); |
||||
|
if (stk.hasMoreTokens()) { |
||||
|
pass = stk.nextToken(); |
||||
|
System.out.println(" : pass = " + pass); |
||||
|
} else { |
||||
|
throw new Exception("Syntax error at '" + token + "'"); |
||||
|
} |
||||
|
|
||||
|
} else if (token.equals("connect")) { |
||||
|
System.out.print("[ CONNECT ] (login = " + user + ", pass = " + pass + ")"); |
||||
|
sessionId = bankRef.connect(user, pass); |
||||
|
System.out.println(" : sessionId = " + sessionId); |
||||
|
if (sessionId == 0) { |
||||
|
System.out.println("wrong login or password"); |
||||
|
} |
||||
|
} else if (token.equals("disconnect")) { |
||||
|
System.out.print("[ DISCONNECT ] (sessionId = " + sessionId + ")"); |
||||
|
bankRef.disconnect(sessionId); |
||||
|
sessionId = -1; |
||||
|
System.out.println(" : OK"); |
||||
|
} else if (token.equals("create")) { |
||||
|
accNum = bankRef.create(sessionId); |
||||
|
if (accNum == 0) { |
||||
|
System.out.println("Please log-in before create account: login <user_login> pass <user_password> connect "); |
||||
|
} else { |
||||
|
System.out.print("[ CREATE ] (sessionId = " + sessionId + ")"); |
||||
|
System.out.println(" : accNum = " + accNum); |
||||
|
System.out.println(" : OK"); |
||||
|
} |
||||
|
} else if (token.equals("getacc")) { |
||||
|
if (stk.hasMoreTokens()) { |
||||
|
accNum = Integer.parseInt(stk.nextToken()); |
||||
|
} else { |
||||
|
throw new Exception("Syntax error at '" + token + "'"); |
||||
|
} |
||||
|
System.out.print("[ GET ACCOUNT ] (sessionId = " + sessionId + ", accNum = " + accNum + ")"); |
||||
|
accRef = bankRef.getAccount(accNum, sessionId); |
||||
|
System.out.println(" : OK"); |
||||
|
} else if (token.equals("deposit")) { |
||||
|
int m; |
||||
|
if (stk.hasMoreTokens()) { |
||||
|
m = Integer.parseInt(stk.nextToken()); |
||||
|
} else { |
||||
|
throw new Exception("Syntax error at '" + token + "'"); |
||||
|
} |
||||
|
|
||||
|
System.out.print("[ DEPOSIT ] (sessionId = " + sessionId + ", accNum = " + accNum + ", amount = " + m + ")"); |
||||
|
accRef.deposit(m); |
||||
|
System.out.println(" : OK"); |
||||
|
} else if (token.equals("withdraw")) { |
||||
|
int m; |
||||
|
if (stk.hasMoreTokens()) { |
||||
|
m = Integer.parseInt(stk.nextToken()); |
||||
|
} else { |
||||
|
throw new Exception("Syntax error at '" + token + "'"); |
||||
|
} |
||||
|
System.out.print("[ WITHDRAW ] (sessionId = " + sessionId + ", accNum = " + accNum + ", amount = " + m + ")"); |
||||
|
accRef.withdraw(m); |
||||
|
System.out.println(" : OK"); |
||||
|
} else if (token.equals("balance")) { |
||||
|
System.out.print("[ BALANCE ] (sessionId = " + sessionId + ", accNum = " + accNum + ")"); |
||||
|
int b = accRef.balance(); |
||||
|
System.out.println(" : balance = " + b); |
||||
|
} else if (token.equals("quit")) { |
||||
|
quit = true; |
||||
|
} else if (token.equals("del")) { |
||||
|
bankRef.del(accNum, sessionId); |
||||
|
System.out.println("[ DEL ] (accNum = " + accNum + ")"); |
||||
|
accNum = -1; |
||||
|
accRef = null; |
||||
|
} else if (token.equals("help")) { |
||||
|
displayHelp(); |
||||
|
} else { |
||||
|
throw new Exception("Syntax error at '" + token + "'"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
System.out.println("\nERROR : " + e) ; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
System.out.println("\n\n\nERROR : " + e) ; |
||||
|
e.printStackTrace(System.out); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
private static void displayHelp() { |
||||
|
System.out.println("Syntax: command [argument]"); |
||||
|
System.out.println("login <user_login>"); |
||||
|
System.out.println("pass <user_password>"); |
||||
|
System.out.println("connect"); |
||||
|
System.out.println("create"); |
||||
|
System.out.println("getacc <account_number>"); |
||||
|
System.out.println("deposit <amount>"); |
||||
|
System.out.println("withdraw <amount>"); |
||||
|
System.out.println("balance"); |
||||
|
System.out.println("disconnect"); |
||||
|
System.out.println("del"); |
||||
|
System.out.println("help"); |
||||
|
System.out.println("quit"); |
||||
|
System.out.println("\nHint: login utest pass ptest is valid"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,201 @@ |
|||||
|
/* |
||||
|
* #(@)BankImpl.java ENSICAEN 2006-04-04 |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author MASSE Nicolas (2004-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2004-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* @version 1.0 |
||||
|
*/ |
||||
|
|
||||
|
package Bank; |
||||
|
|
||||
|
import BankManagement.*; |
||||
|
import java.util.*; |
||||
|
import org.omg.CORBA.*; |
||||
|
import org.omg.PortableServer.*; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* A Bank servant. |
||||
|
*/ |
||||
|
class BankImpl extends BankPOA { |
||||
|
|
||||
|
/** |
||||
|
* Bank servant constructor |
||||
|
*/ |
||||
|
public BankImpl() { |
||||
|
//this.account = account;
|
||||
|
this.currentAccountNumber = 0; |
||||
|
this.currentSessionID = 0; |
||||
|
this.accounts = new HashMap<Integer, AccountImpl>(16); |
||||
|
this.users = new HashMap<String, String>(16); |
||||
|
this.sessions = new HashMap<Integer, String>(16); |
||||
|
|
||||
|
// Workaround : file storage not implemented (not very "corba related")
|
||||
|
// so users are created here and account related data are reinitialized
|
||||
|
// every BankServer relaunch. (interessant kind of periodic revolution ;-) )
|
||||
|
users.put("Thomas", "grouik"); |
||||
|
users.put("Nicolas", "pouet"); |
||||
|
users.put("utest", "ptest"); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Create a new account. If the session is incorrect |
||||
|
* it returns 0; |
||||
|
* |
||||
|
* @param sessionID |
||||
|
* @return the new account number |
||||
|
*/ |
||||
|
public int create (int sessionID) { |
||||
|
int accNumber = 0; |
||||
|
String username = sessions.get(sessionID); |
||||
|
if (username != null) { |
||||
|
accNumber = this.getNextAccountNumber(); |
||||
|
AccountImpl acc = new AccountImpl(username); |
||||
|
|
||||
|
try { |
||||
|
_default_POA().activate_object(acc); |
||||
|
|
||||
|
} catch (org.omg.PortableServer.POAPackage.ServantAlreadyActive e) { |
||||
|
System.err.println(e.getMessage()); |
||||
|
} catch (org.omg.PortableServer.POAPackage.WrongPolicy e) { |
||||
|
System.err.println(e.getMessage()); |
||||
|
} |
||||
|
|
||||
|
this.accounts.put(accNumber, acc); |
||||
|
System.out.println("User " + username + " create a new account with number: " + accNumber + "(session id: " + sessionID + ")" ); |
||||
|
} else { |
||||
|
System.out.println("Invalid session id: " + sessionID); |
||||
|
} |
||||
|
|
||||
|
return accNumber; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* Provide an account stub. |
||||
|
* |
||||
|
* @param sessionID |
||||
|
* @param acc_num |
||||
|
* @return the account stub |
||||
|
*/ |
||||
|
public BankManagement.Account getAccount (int acc_num, int sessionID) throws BankManagement.no_such_account { |
||||
|
String username = null; |
||||
|
AccountImpl acc = null; |
||||
|
Account aref = null; |
||||
|
|
||||
|
username = this.sessions.get(sessionID); |
||||
|
|
||||
|
if (username != null) { |
||||
|
acc = this.accounts.get(acc_num); |
||||
|
} else { |
||||
|
System.out.println("Invalid session id: " + sessionID); |
||||
|
throw new BankManagement.no_such_account(); |
||||
|
} |
||||
|
|
||||
|
if ((acc == null || !(acc.getUsername().equals(username)))) { |
||||
|
System.out.println("No account " + acc_num + " for user " + username +" (session id: " + sessionID + ")"); |
||||
|
throw new BankManagement.no_such_account(); |
||||
|
} |
||||
|
|
||||
|
System.out.println("Provide account " + acc_num + " to " + username + " (session id: " + sessionID + ")"); |
||||
|
|
||||
|
try { |
||||
|
//get object reference from the servant
|
||||
|
//aref = AccountHelper.narrow(_default_POA().servant_to_reference(acc));
|
||||
|
|
||||
|
|
||||
|
|
||||
|
// aref = acc._this(); // doesn't work, WHY ?????
|
||||
|
aref = AccountHelper.narrow(this._default_POA().servant_to_reference(acc)); |
||||
|
|
||||
|
} catch (Exception e){} |
||||
|
|
||||
|
return aref; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* Connect a user and give him a session id or 0 if login |
||||
|
* or password are wrong. |
||||
|
* |
||||
|
* @param login |
||||
|
* @param password |
||||
|
* @return the session id |
||||
|
*/ |
||||
|
public int connect (String login, String password) { |
||||
|
String storedPassword = this.users.get(login); |
||||
|
int sessionID = 0; |
||||
|
|
||||
|
if ((storedPassword == null) || ! password.equals(storedPassword)) { |
||||
|
System.out.println("Connection refused for user " + login); |
||||
|
} else { |
||||
|
sessionID = this.getNextSessionID(); |
||||
|
this.sessions.put(sessionID, login); |
||||
|
System.out.println("User " + login + " connected (session id: " + sessionID + ")"); |
||||
|
} |
||||
|
|
||||
|
return sessionID; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Discard a session id so the user have to log-in |
||||
|
* again to send commands. |
||||
|
* |
||||
|
* @param sessionID |
||||
|
*/ |
||||
|
public void disconnect (int sessionID) { |
||||
|
String login = null; |
||||
|
login = this.sessions.remove(sessionID); |
||||
|
|
||||
|
if (login != null) { |
||||
|
System.out.println("User " + login + " is now disconnected (previously connected with session id: " + sessionID + ")"); |
||||
|
} else { |
||||
|
System.out.println("Error disconnecting session: session " + sessionID + " unknown"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* Destroy an account. But where is the remaining cash deposited?? |
||||
|
* |
||||
|
* @param acc_num |
||||
|
* @param sessionID |
||||
|
*/ |
||||
|
public void del (int acc_num, int sessionID) { |
||||
|
String username = null; |
||||
|
username = this.sessions.get(sessionID); |
||||
|
|
||||
|
if (username != null) { |
||||
|
AccountImpl acc = accounts.get(acc_num); |
||||
|
if (acc.getUsername().equals(username)) { |
||||
|
this.accounts.remove(sessionID); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private int getNextAccountNumber() { |
||||
|
return ++ this.currentAccountNumber; |
||||
|
} |
||||
|
|
||||
|
private int getNextSessionID() { |
||||
|
return ++ this.currentSessionID; |
||||
|
} |
||||
|
|
||||
|
private Account account; |
||||
|
private int currentAccountNumber; |
||||
|
private int currentSessionID; |
||||
|
private Map<Integer, AccountImpl> accounts; |
||||
|
private Map<String, String> users; |
||||
|
private Map<Integer, String> sessions; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,87 @@ |
|||||
|
/* |
||||
|
* #(@)BankServer.java ENSICAEN 2005 |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
package Bank; |
||||
|
|
||||
|
import BankManagement.*; |
||||
|
|
||||
|
import org.omg.CosNaming.*; |
||||
|
import org.omg.CosNaming.NamingContextPackage.*; |
||||
|
import org.omg.CORBA.*; |
||||
|
import org.omg.PortableServer.*; |
||||
|
import org.omg.PortableServer.POA; |
||||
|
|
||||
|
import java.util.Properties; |
||||
|
|
||||
|
/** |
||||
|
* Make a bank servant availlable on the corba bus |
||||
|
*/ |
||||
|
public class BankServer { |
||||
|
|
||||
|
/** |
||||
|
* Lauch the bank server. |
||||
|
*/ |
||||
|
public static void main(String args[]) { |
||||
|
|
||||
|
String host = "localhost"; |
||||
|
String port = "1050"; |
||||
|
|
||||
|
if (args.length >= 1) { |
||||
|
port = args[0]; |
||||
|
} |
||||
|
|
||||
|
if (args.length >= 2) { |
||||
|
host = args[1]; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
try{ |
||||
|
// Step 1: Instantiate the ORB
|
||||
|
ORB orb = ORB.init(new String[] {"-ORBInitialPort", host, "-ORBInitialPort", port }, null); |
||||
|
|
||||
|
// Step 2: Instantiate the servant
|
||||
|
BankImpl bankServ = new BankImpl(); |
||||
|
|
||||
|
// get reference to rootpoa & activate the POAManager
|
||||
|
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); |
||||
|
rootpoa.the_POAManager().activate(); |
||||
|
|
||||
|
rootpoa.activate_object(bankServ); |
||||
|
|
||||
|
|
||||
|
// Resolve RootNaming context and bind a name for the
|
||||
|
// servant.
|
||||
|
// NOTE: If the Server is persistent in nature then using Persistent
|
||||
|
// Name Service is a good choice. Even if ORBD is restarted the Name
|
||||
|
// Bindings will be intact. To use Persistent Name Service use
|
||||
|
// 'NameService' as the key for resolve_initial_references() when
|
||||
|
// ORBD is running.
|
||||
|
org.omg.CORBA.Object obj = orb.resolve_initial_references("NameService" ); |
||||
|
NamingContextExt rootContext = NamingContextExtHelper.narrow(obj); |
||||
|
|
||||
|
NameComponent[] nc = rootContext.to_name("Bank"); |
||||
|
rootContext.rebind(nc, rootpoa.servant_to_reference(bankServ)); |
||||
|
System.out.println("Bank server ready and waiting ..."); |
||||
|
|
||||
|
// wait for invocations from clients
|
||||
|
orb.run(); |
||||
|
} |
||||
|
|
||||
|
catch (Exception e) { |
||||
|
System.err.println("ERROR: " + e); |
||||
|
e.printStackTrace(System.out); |
||||
|
} |
||||
|
|
||||
|
System.out.println("Bank Server Exiting ..."); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,32 @@ |
|||||
|
/* |
||||
|
* #(@)BankManagement.idl ENSICAEN 2005 |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
module BankManagement { |
||||
|
exception no_such_account { }; |
||||
|
|
||||
|
interface Account { |
||||
|
void deposit(in long amount); |
||||
|
void withdraw(in long amount); |
||||
|
long balance(); |
||||
|
string operations(); |
||||
|
string getUsername(); |
||||
|
}; |
||||
|
|
||||
|
interface Bank { |
||||
|
long create(in long sessionID); |
||||
|
Account getAccount(in long acc_num, in long sessionID) raises (no_such_account); |
||||
|
long connect(in string login, in string password); |
||||
|
void disconnect(in long sessionID); |
||||
|
void del(in long acc_num, in long sessionID); |
||||
|
}; |
||||
|
}; |
||||
|
|
||||
@ -0,0 +1,38 @@ |
|||||
|
#
|
||||
|
# Makefile ENSICAEN 2005
|
||||
|
#
|
||||
|
# MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net>
|
||||
|
# LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net>
|
||||
|
#
|
||||
|
# ENSICAEN
|
||||
|
# 6 Boulevard Marechal Juin
|
||||
|
# F-14050 Caen Cedex
|
||||
|
#
|
||||
|
# Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre
|
||||
|
# reproduit, utilise ou modifie sans l'avis express de ses auteurs.
|
||||
|
#
|
||||
|
|
||||
|
IDLJ = idlj |
||||
|
IDLJFLAGS = -fall |
||||
|
JAVACFLAGS = -Xlint |
||||
|
JAVA_CLASS = Bank/BankServer.class Bank/BankClient.class Bank/AccountImpl.class Bank/BankImpl.class |
||||
|
|
||||
|
all: common client server |
||||
|
|
||||
|
server: Bank/BankServer.class |
||||
|
client: Bank/BankClient.class |
||||
|
|
||||
|
common: BankManagement Bank/AccountImpl.class Bank/BankImpl.class |
||||
|
|
||||
|
$(JAVA_CLASS) : %.class : %.java |
||||
|
$(JAVAC) $(JAVACFLAGS) $< |
||||
|
|
||||
|
BankManagement: BankManagement.idl |
||||
|
$(IDLJ) $(IDLJFLAGS) $< |
||||
|
test -d $@ || exit 1 |
||||
|
touch $@ |
||||
|
|
||||
|
clean: |
||||
|
rm -rf BankManagement |
||||
|
rm -f Bank/*.class |
||||
|
|
||||
@ -0,0 +1,57 @@ |
|||||
|
#
|
||||
|
# Makefile ENSICAEN 2005
|
||||
|
#
|
||||
|
# MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net>
|
||||
|
# LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net>
|
||||
|
#
|
||||
|
# ENSICAEN
|
||||
|
# 6 Boulevard Marechal Juin
|
||||
|
# F-14050 Caen Cedex
|
||||
|
#
|
||||
|
# Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre
|
||||
|
# reproduit, utilise ou modifie sans l'avis express de ses auteurs.
|
||||
|
#
|
||||
|
|
||||
|
#
|
||||
|
# Description du makefile
|
||||
|
#
|
||||
|
|
||||
|
#
|
||||
|
# Version : 1.0.0
|
||||
|
#
|
||||
|
# Fait : Detail de ce qui a ete fait.
|
||||
|
#
|
||||
|
# A faire : Detail de ce qui n'a pas ete fait.
|
||||
|
#
|
||||
|
|
||||
|
CXX = g++ |
||||
|
LD = g++ |
||||
|
CFLAGS = -Wall --pedantic |
||||
|
CPPFLAGS = -I./ |
||||
|
|
||||
|
|
||||
|
OBJECTS = ex2.o ex3.o porte.o |
||||
|
|
||||
|
EXEC = ex2 ex3 |
||||
|
|
||||
|
all : $(EXEC) porte |
||||
|
|
||||
|
ex1.o : %.o : %.cpp %.h |
||||
|
$(CXX) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
||||
|
|
||||
|
ex1.o : ex1.h |
||||
|
|
||||
|
$(OBJECTS) : %.o : %.cpp |
||||
|
$(CXX) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
||||
|
|
||||
|
$(EXEC) : % : %.o ex1.o |
||||
|
$(LD) ex1.o $< -o $@ |
||||
|
|
||||
|
porte : porte.o |
||||
|
$(LD) ex1.o $< -o $@ |
||||
|
|
||||
|
clean: |
||||
|
rm -f ex1 ex2 ex3 porte *~ *.o |
||||
|
|
||||
|
.PHONY: all clean |
||||
|
|
||||
@ -0,0 +1,92 @@ |
|||||
|
/**
|
||||
|
* #(@)ex1.cpp ENSICAEN 2005-09-20 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
#include "ex1.h" |
||||
|
|
||||
|
void lectureClavierTableau(int * tableau, int taille) { |
||||
|
cout << "Veuiler saisir " << taille << " entiers" << endl; |
||||
|
for (int i = 0; i < taille; i++) { |
||||
|
cin >> tableau[i]; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void affichageTableau(int * tableau, int taille) { |
||||
|
cout << "Affichage d'un tableau contenant " << taille << " valeurs" << endl; |
||||
|
|
||||
|
for (int i = 0; i < taille; i++) { |
||||
|
cout << tableau[i] << endl; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void echange(int * entier1, int * entier2) { |
||||
|
int tmp = *entier1; |
||||
|
*entier1 = *entier2; |
||||
|
*entier2 = tmp; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void echange(int & entier1, int & entier2) { |
||||
|
int tmp = entier1; |
||||
|
entier1 = entier2; |
||||
|
entier2 = tmp; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
int & getMin(int * const tableau, int taille) { |
||||
|
int min = tableau[0]; |
||||
|
int idMin = 0; |
||||
|
|
||||
|
for (int i = 1; i < taille; i ++) { |
||||
|
if (tableau[i] < min) { |
||||
|
min = tableau[i]; |
||||
|
idMin = i; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return tableau[idMin]; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
int & getMax(int * const tableau, int taille) { |
||||
|
int max = tableau[0]; |
||||
|
int idMax = 0; |
||||
|
|
||||
|
for (int i = 1; i < taille; i ++) { |
||||
|
if (tableau[i] > max) { |
||||
|
max = tableau[i]; |
||||
|
idMax = i; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return tableau[idMax]; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
int & getRandom(int * const tableau, int taille) { |
||||
|
// récupératoin d'un nombre aléatoire x, tel que 0 <= x < taille
|
||||
|
// à l'aide des bits de poids fort du résultat de rand
|
||||
|
int index = static_cast<int>(taille * (rand() / (RAND_MAX + 1.0))); |
||||
|
|
||||
|
return tableau[index]; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void melanger(int * const tableau, int taille, int nbEchange) { |
||||
|
for (int i = nbEchange - 1; i >= 0; i--) { |
||||
|
echange(getRandom(tableau, taille), getRandom(tableau, taille)); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,122 @@ |
|||||
|
/**
|
||||
|
* #(@)ex1.h ENSICAEN 2005-09-20 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Premier TP, découverte du C++, des entrées/sorties, des références |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
#include <cstdlib> |
||||
|
#include <ctime> |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Lecture au clavier d'un tableau d'entier |
||||
|
* |
||||
|
* @param tableau le tableau à remplir |
||||
|
* @param taille la taille du tableau |
||||
|
*/ |
||||
|
void lectureClavierTableau(int * tableau, int taille); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Affichage des éléments du tableau sur la sortie standard |
||||
|
* |
||||
|
* Lecture au clavier d'un tableau d'entier |
||||
|
* |
||||
|
* @param tableau le tableau à afficher |
||||
|
* @param taille la taille du tableau |
||||
|
*/ |
||||
|
void affichageTableau(int * tableau, int taille); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Echange de deux entiers, passage par adresse/pointeur |
||||
|
* |
||||
|
* @param entier1 adresse du premier entier |
||||
|
* @param entier2 adresse du second entier |
||||
|
*/ |
||||
|
void echange(int * entier1, int * entier2); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Echange de deux entiers, passage par référence |
||||
|
* |
||||
|
* @param entier1 premier entier |
||||
|
* @param entier2 second entier |
||||
|
*/ |
||||
|
void echange(int & entier1, int & entier2); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Echange de deux entiers, passage par valeurs |
||||
|
* (cette fonction est volontairement défaillante, il n'est pas |
||||
|
* possible d'échanger deux variable à l'aide d'une fonction |
||||
|
* à qui l'on ne passe que les valeurs des variables. De plus, |
||||
|
* elle est commentée car si elle est disponible, elle rend la |
||||
|
* résolution de surcharge ambigue entre la version echange(int, int) |
||||
|
* et la version echange(int &, int &), le compilateur ne pouvant déterminer |
||||
|
* laquelle des deux doit etre appelée, les deux acceptant des entiers en |
||||
|
* parametres) |
||||
|
* |
||||
|
* @param entier1 premier entier |
||||
|
* @param entier2 second entier |
||||
|
*/ |
||||
|
/*
|
||||
|
void echange(int entier1, int entier2) { |
||||
|
int tmp = entier1; |
||||
|
entier1 = entier2; |
||||
|
entier2 = tmp; |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Recherche et retour du minimum d'un tableau d'entiers |
||||
|
* |
||||
|
* @param tableau le tableau dont il faut retourner le minimum |
||||
|
* @param taille la taille du tableau |
||||
|
*/ |
||||
|
int & getMin(int * const tableau, int taille); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Recherche et retour du maximum d'un tableau d'entiers |
||||
|
* |
||||
|
* @param tableau le tableau dont il faut retourner le maximum |
||||
|
* @param taille la taille du tableau |
||||
|
*/ |
||||
|
int & getMax(int * const tableau, int taille); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Retourne un élément tiré au hasard dans le tableau |
||||
|
* |
||||
|
* @param tableau le tableau dont il faut retourner le maximum |
||||
|
* @param taille la taille du tableau |
||||
|
*/ |
||||
|
int & getRandom(int * const tableau, int taille); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Effectue le mélange du tableau l'aide d'un nombre |
||||
|
* donné d'échnges |
||||
|
* |
||||
|
* @param tableau le tableau à melanger |
||||
|
* @param taille la taille du tableau |
||||
|
* @param nbEchange le nombre d'échange à faire |
||||
|
*/ |
||||
|
void melanger(int * const tableau, int taille, int nbEchange); |
||||
@ -0,0 +1,45 @@ |
|||||
|
/**
|
||||
|
* #(@)ex2.cpp ENSICAEN 2005-09-20 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Exercice 2 du TP 1 de C++. |
||||
|
*/ |
||||
|
|
||||
|
#include "ex1.h" |
||||
|
|
||||
|
/**
|
||||
|
* la taille maximale du tableau |
||||
|
*/ |
||||
|
#define TAILLE_MAX 10 |
||||
|
|
||||
|
/**
|
||||
|
* Fonction principale. |
||||
|
* - demande à l'utilisateur de remplir un tableau |
||||
|
* - permute le mini et le maxi du tableau |
||||
|
* - affiche le tableau |
||||
|
* |
||||
|
* La ligne de commande doit préciser le nombre de case du tableau, qui |
||||
|
* doit etre strictement positive et inférieure ou égale à TAILLE_MAX |
||||
|
*/ |
||||
|
int main(int argc, char ** argv) { |
||||
|
int tableau[TAILLE_MAX]; |
||||
|
|
||||
|
// récupération sur la ligne de commande du parametre "taille du tableau"
|
||||
|
int taille = int(argv[1]); |
||||
|
lectureClavierTableau(tableau, taille); |
||||
|
echange(getMin(tableau, taille), getMax(tableau, taille)); |
||||
|
affichageTableau(tableau, taille); |
||||
|
} |
||||
|
|
||||
|
|
||||
@ -0,0 +1,45 @@ |
|||||
|
/**
|
||||
|
* #(@)ex3.cpp ENSICAEN 2005-09-20 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Exercice 3 du TP 1 de C++. |
||||
|
*/ |
||||
|
|
||||
|
#include "ex1.h" |
||||
|
|
||||
|
/**
|
||||
|
* la taille maximale du tableau |
||||
|
*/ |
||||
|
#define TAILLE_MAX 10 |
||||
|
|
||||
|
/**
|
||||
|
* Fonction principale. |
||||
|
* - demande à l'utilisateur de remplir un tableau |
||||
|
* - permute le mini et le maxi du tableau |
||||
|
* - affiche le tableau |
||||
|
* |
||||
|
* La ligne de commande doit préciser le nombre de case du tableau, qui |
||||
|
* doit etre strictement positive et inférieure ou égale à TAILLE_MAX |
||||
|
*/ |
||||
|
int main(int argc, char ** argv) { |
||||
|
int tableau[TAILLE_MAX]; |
||||
|
|
||||
|
// récupération sur la ligne de commande du parametre "taille du tableau"
|
||||
|
int taille = int(argv[1]); |
||||
|
lectureClavierTableau(tableau, taille); |
||||
|
echange(getMin(tableau, taille), getMax(tableau, taille)); |
||||
|
affichageTableau(tableau, taille); |
||||
|
} |
||||
|
|
||||
|
|
||||
@ -0,0 +1,154 @@ |
|||||
|
/**
|
||||
|
* #(@)porte.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Ce programme permet de definir des fonctions logiques en intention |
||||
|
* et de les utiliser. Il ne prend pas de parametre. |
||||
|
* |
||||
|
* |
||||
|
* Trace d'execution |
||||
|
* ------------------- |
||||
|
* |
||||
|
* Table de verite par defaut : |
||||
|
* +-----+-----+-----+ |
||||
|
* |b1\b2| 0 | 1 | |
||||
|
* +-----+-----+-----+ |
||||
|
* | 0 | 0 | 0 | |
||||
|
* +-----+-----+-----+ |
||||
|
* | 1 | 0 | 0 | |
||||
|
* +-----+-----+-----+ |
||||
|
* |
||||
|
* Table de verite de la fonction ET : |
||||
|
* +-----+-----+-----+ |
||||
|
* |b1\b2| 0 | 1 | |
||||
|
* +-----+-----+-----+ |
||||
|
* | 0 | 0 | 0 | |
||||
|
* +-----+-----+-----+ |
||||
|
* | 1 | 0 | 1 | |
||||
|
* +-----+-----+-----+ |
||||
|
* |
||||
|
* Test OK |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
/**
|
||||
|
* Faire retourner par une fonction une reference a une variable locale |
||||
|
* est une erreur. Mais si cette variable est declaree static, alors cela |
||||
|
* devient possible. |
||||
|
* |
||||
|
* En effet, lorsque l'on declare une variable locale a une fonction, cette |
||||
|
* variable est alouee sur la pile et une fois la fonction terminee, la pile |
||||
|
* est reajustee et la variable n'existe plus. Faire reference a cette |
||||
|
* variable est incorrect et conduit a des resultats errones. |
||||
|
* |
||||
|
* Mais lorsque l'on declare une variable "static", le compilateur |
||||
|
* reserve une zone memoire pendant toute l'execution du programme ; on |
||||
|
* peut alors y faire reference à partir de n'importe quel moment de |
||||
|
* l'execution du programme. |
||||
|
* |
||||
|
* Le fait de retourner une reference permet d'utiliser l'appel de fonction |
||||
|
* comme "lvalue", c'est une construction similaire à la suivante en C : |
||||
|
* |
||||
|
* strncpy(dst, src, size)[size - 1] = '\0'; |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* @version 1.0 |
||||
|
* |
||||
|
* @Fait Enonce + affichage de la table de verite. |
||||
|
* |
||||
|
* @Afaire - |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Cette fonction dispose d'un tableau statique de 4 booleens a deux entrees |
||||
|
* qui definit la table de verite de la fonction logique. Les deux parametres |
||||
|
* b1 et b2 sont les indices dans tableau du resultat de la fonction logique |
||||
|
* pour ces deux valeurs. |
||||
|
* |
||||
|
* Elle retourne une reference vers l'element du tableau qui contient le |
||||
|
* resultat de la fonction logique, ce qui permet d'utiliser un appel de |
||||
|
* cette fonction comme "lvalue". |
||||
|
* |
||||
|
*/ |
||||
|
bool & porte(bool b1, bool b2) { |
||||
|
static bool tableVerite[2][2] = {{false, false}, {false, false}}; |
||||
|
|
||||
|
return tableVerite[int(b1)][int(b2)]; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Cette fonction affiche la table de verite definie en intention par |
||||
|
* l'intermediaire de la fonction porte(bool, bool). |
||||
|
* |
||||
|
* @param st le flux de sortie. |
||||
|
*/ |
||||
|
void afficheTableVerite(ostream & st) { |
||||
|
int b1, b2; |
||||
|
|
||||
|
// Entete de la table de verite
|
||||
|
st << "+-----+-----+-----+" << endl; |
||||
|
st << "|b1\\b2| 0 | 1 |" << endl; |
||||
|
st << "+-----+-----+-----+" << endl; |
||||
|
|
||||
|
// Parcours ligne / ligne
|
||||
|
for (b1 = 0; b1 <= 1; b1++) { |
||||
|
// Entete de ligne
|
||||
|
st << "| " << b1 << " |"; |
||||
|
|
||||
|
// Parcours colonne par colonne
|
||||
|
for (b2 = 0; b2 <= 1; b2++) { |
||||
|
st << " " << porte(bool(b1), bool(b2)) << " |"; |
||||
|
} |
||||
|
|
||||
|
// Fin de la ligne
|
||||
|
st << endl; |
||||
|
|
||||
|
// Separation entre deux lignes
|
||||
|
st << "+-----+-----+-----+" << endl; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Point d'entree du programme. Ce programme n'accepte pas de parametres. |
||||
|
*/ |
||||
|
int main(int argc, char ** argv) { |
||||
|
cout << "Table de verite par defaut :" << endl; |
||||
|
afficheTableVerite(cout); |
||||
|
cout << endl; |
||||
|
|
||||
|
/* Definition de la fonction logique ET par extention */ |
||||
|
porte(true, false) = false; |
||||
|
porte(false, true) = false; |
||||
|
porte(true, true) = true; |
||||
|
porte(false, false) = false; |
||||
|
|
||||
|
cout << "Table de verite de la fonction ET :" << endl; |
||||
|
afficheTableVerite(cout); |
||||
|
cout << endl; |
||||
|
|
||||
|
if (porte(true, true)) |
||||
|
cout << "Test OK" << endl; |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,51 @@ |
|||||
|
#
|
||||
|
# Makefile ENSICAEN 2005
|
||||
|
#
|
||||
|
# MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net>
|
||||
|
# LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net>
|
||||
|
#
|
||||
|
# ENSICAEN
|
||||
|
# 6 Boulevard Marechal Juin
|
||||
|
# F-14050 Caen Cedex
|
||||
|
#
|
||||
|
# Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre
|
||||
|
# reproduit, utilise ou modifie sans l'avis express de ses auteurs.
|
||||
|
#
|
||||
|
|
||||
|
#
|
||||
|
# Description du makefile
|
||||
|
#
|
||||
|
|
||||
|
CXX = g++ |
||||
|
LD = g++ |
||||
|
CFLAGS = -Wall --pedantic -g |
||||
|
#CFLAGS = -Wall
|
||||
|
CPPFLAGS = -I./ |
||||
|
|
||||
|
|
||||
|
OBJECTS = complex.o |
||||
|
|
||||
|
EXEC = checkComplex |
||||
|
|
||||
|
all : $(EXEC) |
||||
|
|
||||
|
checkComplex : checkComplex.o |
||||
|
|
||||
|
checkComplex.o : %.o : %.cpp |
||||
|
$(CXX) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
||||
|
|
||||
|
|
||||
|
$(OBJECTS) : %.o : %.cpp |
||||
|
$(CXX) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
||||
|
|
||||
|
$(EXEC) : % : %.o $(OBJECTS) |
||||
|
$(LD) $^ -o $@ |
||||
|
|
||||
|
clean: |
||||
|
rm -f *~ *.o |
||||
|
|
||||
|
distclean: clean |
||||
|
rm -f $(EXEC) |
||||
|
|
||||
|
.PHONY: all clean distclean |
||||
|
|
||||
@ -0,0 +1,78 @@ |
|||||
|
/**
|
||||
|
* #(@)checkComplex.cpp ENSICAEN 2005-09-29 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Test de la classe complexe, objet du TP2 |
||||
|
*/ |
||||
|
|
||||
|
#include "complex.h" |
||||
|
|
||||
|
int main(int argc, char ** argv) { |
||||
|
Complex a(1, 1); |
||||
|
Complex b(3, 4); |
||||
|
Complex c; |
||||
|
|
||||
|
std::cout << "a: "; |
||||
|
a.writeTo(std::cout); |
||||
|
|
||||
|
std::cout << std::endl << "b: "; |
||||
|
b.writeTo(std::cout); |
||||
|
|
||||
|
std::cout << std::endl << "c: "; |
||||
|
c.writeTo(std::cout); |
||||
|
std::cout << std::endl; |
||||
|
|
||||
|
std::cout << std::endl << "a * b: " << std::endl; |
||||
|
(a * b).writeTo(std::cout); |
||||
|
std::cout << std::endl; |
||||
|
|
||||
|
std::cout << std::endl << "a - b: " << std::endl; |
||||
|
(a - b).writeTo(std::cout); |
||||
|
std::cout << std::endl; |
||||
|
|
||||
|
std::cout << std::endl << "a + b: " << std::endl; |
||||
|
(a + b).writeTo(std::cout); |
||||
|
std::cout << std::endl; |
||||
|
|
||||
|
std::cout << "Normalisation" << std::endl; |
||||
|
c = normalize(a); |
||||
|
c.writeTo(std::cout); |
||||
|
std::cout << std::endl; |
||||
|
std::cout << "Fin de la normalisation" << std::endl << std::endl; |
||||
|
|
||||
|
std::cout << "Rotation" << std::endl; |
||||
|
c = b.rotate(a, M_PI / 2); |
||||
|
c.writeTo(std::cout); |
||||
|
std::cout << std::endl; |
||||
|
std::cout << "Fin de la rotation" << std::endl << std::endl; |
||||
|
|
||||
|
std::cout << "Debut de 'Complex d = getMax(a, b)'" << std::endl; |
||||
|
Complex d = getMax(a, b); |
||||
|
std::cout << "Fin de 'Complex d = getMax(a, b)'" << std::endl << std::endl; |
||||
|
|
||||
|
|
||||
|
std::cout << "Debut de 'c = getMax(a, b)'" << std::endl; |
||||
|
c = getMax(a, b); |
||||
|
std::cout << "Fin de 'c = getMax(a, b)'" << std::endl << std::endl; |
||||
|
|
||||
|
std::cout << "Debut de l'initialisation du tableau (taille 10)" << std::endl; |
||||
|
Complex tab[10]; |
||||
|
std::cout << "Fin de l'initialisation du tableau" << std::endl << std::endl; |
||||
|
|
||||
|
std::cout << "Appel de la fonction remplirTableau(3, tab)" << std::endl; |
||||
|
remplirTableau(3, tab); |
||||
|
std::cout << "Fin de l'appel" << std::endl << std::endl; |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
@ -0,0 +1,178 @@ |
|||||
|
/**
|
||||
|
* #(@)complex.cpp ENSICAEN 2005-02-27 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
#include "complex.h" |
||||
|
#include <cmath> |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
Complex::~Complex() { |
||||
|
cout << "---Complex[" << this << "]("; |
||||
|
this->writeTo(cout); |
||||
|
cout << ")" << endl; |
||||
|
} |
||||
|
|
||||
|
Complex::Complex(double re, double im) : _re(re), _im(im) { |
||||
|
cout << "+++Complex[" << this << "](" << re << ", " << im << ")" << endl; |
||||
|
} |
||||
|
|
||||
|
Complex::Complex(const Complex & cpx) { |
||||
|
cout << "rrrComplex[" << this << "]("; |
||||
|
cpx.writeTo(cout); |
||||
|
cout << ")" << endl; |
||||
|
|
||||
|
this->setRealPart(cpx.getRealPart()); |
||||
|
this->setImaginaryPart(cpx.getImaginaryPart()); |
||||
|
} |
||||
|
|
||||
|
double Complex::getRealPart() const { |
||||
|
return _re; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
double Complex::getImaginaryPart() const { |
||||
|
return _im; |
||||
|
} |
||||
|
|
||||
|
void Complex::setRealPart(double re) { |
||||
|
_re = re; |
||||
|
} |
||||
|
|
||||
|
void Complex::setImaginaryPart(double im) { |
||||
|
_im = im; |
||||
|
} |
||||
|
|
||||
|
double Complex::getMagnitude() const { |
||||
|
double re = this->getRealPart(); |
||||
|
double im = this->getImaginaryPart(); |
||||
|
|
||||
|
return std::sqrt((re * re) + (im * im)); |
||||
|
} |
||||
|
|
||||
|
double Complex::getAngle() const { |
||||
|
double angle = 0; |
||||
|
double r = this->getRealPart(); |
||||
|
double i = this->getImaginaryPart(); |
||||
|
|
||||
|
if (r == 0) { |
||||
|
if (i > 0) { |
||||
|
angle = M_PI_2; |
||||
|
} else if (i < 0) { |
||||
|
angle = - M_PI_2; |
||||
|
} else { |
||||
|
angle = FP_NAN; |
||||
|
} |
||||
|
} else if (r > 0) { |
||||
|
angle = std::atan(i / r); |
||||
|
} else { |
||||
|
if (i > 0) { |
||||
|
angle = M_PI - std::atan(i / r); |
||||
|
} else { |
||||
|
angle = - M_PI + std::atan(i / r); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return angle; |
||||
|
} |
||||
|
|
||||
|
Complex Complex::rotate(Complex & c, double angle) const { |
||||
|
Complex tmp = (*this) - c; |
||||
|
Complex tmp2 = tmp * Complex(cos(angle), sin(angle)); |
||||
|
return tmp2 + c; |
||||
|
} |
||||
|
|
||||
|
void Complex::writeTo(std::ostream & output) const { |
||||
|
output << this->getRealPart() << " + i * " << this->getImaginaryPart(); |
||||
|
} |
||||
|
|
||||
|
Complex Complex::operator+(const Complex & c2) const { |
||||
|
return sum(*this, c2); |
||||
|
} |
||||
|
|
||||
|
Complex Complex::operator-(const Complex & c2) const { |
||||
|
return ::minus(*this, c2); |
||||
|
} |
||||
|
|
||||
|
Complex Complex::operator*(const Complex & c2) const { |
||||
|
return product(*this, c2); |
||||
|
} |
||||
|
|
||||
|
Complex & Complex::operator=(const Complex & c2) { |
||||
|
cout << "===Complex[" << &c2 << "]("; |
||||
|
c2.writeTo(cout); |
||||
|
cout << ") >> [" << this << "]("; |
||||
|
this->writeTo(cout); |
||||
|
cout << ")"<< endl; |
||||
|
this->setImaginaryPart(c2.getImaginaryPart()); |
||||
|
this->setRealPart(c2.getRealPart()); |
||||
|
|
||||
|
return *this; |
||||
|
} |
||||
|
|
||||
|
void Complex::swapRealAndImaginaryPart() { |
||||
|
double tmp = this->getImaginaryPart(); |
||||
|
this->setImaginaryPart(this->getRealPart()); |
||||
|
this->setRealPart(tmp); |
||||
|
} |
||||
|
|
||||
|
Complex product(const Complex & cpx1, const Complex & cpx2) { |
||||
|
double re1 = cpx1.getRealPart(); |
||||
|
double re2 = cpx2.getRealPart(); |
||||
|
double im1 = cpx1.getImaginaryPart(); |
||||
|
double im2 = cpx2.getImaginaryPart(); |
||||
|
|
||||
|
return Complex((re1 * re2) - (im1 * im2), (re1 * im2) + (im1 * re2)); |
||||
|
} |
||||
|
|
||||
|
Complex sum(const Complex & cpx1, const Complex & cpx2) { |
||||
|
return Complex(cpx1.getRealPart() + cpx2.getRealPart(), |
||||
|
cpx1.getImaginaryPart() + cpx2.getImaginaryPart()); |
||||
|
} |
||||
|
|
||||
|
Complex minus(const Complex & cpx1, const Complex & cpx2) { |
||||
|
return Complex(cpx1.getRealPart() - cpx2.getRealPart(), |
||||
|
cpx1.getImaginaryPart() - cpx2.getImaginaryPart()); |
||||
|
} |
||||
|
|
||||
|
Complex normalize(Complex cpx) { |
||||
|
cout << "La normalisation a commence" << endl; |
||||
|
|
||||
|
double mag = cpx.getMagnitude(); |
||||
|
double r, i; |
||||
|
|
||||
|
r = cpx.getRealPart() / mag; |
||||
|
i = cpx.getImaginaryPart() / mag; |
||||
|
|
||||
|
return Complex(r, i); |
||||
|
} |
||||
|
|
||||
|
Complex & getMax(Complex & c1, Complex & c2) { |
||||
|
Complex & max = c2; |
||||
|
|
||||
|
if (c1.getMagnitude() > c2.getMagnitude()) { |
||||
|
max = c1; |
||||
|
} |
||||
|
|
||||
|
return max; |
||||
|
} |
||||
|
|
||||
|
void remplirTableau(int n, Complex * tab) { |
||||
|
int i; |
||||
|
|
||||
|
for (i = 0; i < n; i++) { |
||||
|
tab[i] = Complex(i, 0); |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,241 @@ |
|||||
|
/**
|
||||
|
* #(@)complex.h ENSICAEN 2005-02-27 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
#ifndef __COMPLEXE_H__ |
||||
|
#define __COMPLEXE_H__ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
/**
|
||||
|
* Définition d'une classe complexe fournissant les services de base |
||||
|
* (voir énoncé TP2) |
||||
|
* |
||||
|
* @author MASSE Nicolas & LIMIN Thomas |
||||
|
* @version 0.0.1 |
||||
|
*/ |
||||
|
class Complex { |
||||
|
|
||||
|
public: |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Constructeur par défaut. |
||||
|
* |
||||
|
* @param re partie réelle du nombre complexe, 0 par défaut |
||||
|
* @param im partie imaginaire du nmbre complexe, 0 par defaut |
||||
|
*/ |
||||
|
Complex(double re = 0, double im = 0); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Construit un complexe de module 1 a partir de son argument. |
||||
|
* |
||||
|
* @param angle l'argument du complexe |
||||
|
*/ |
||||
|
Complex(double angle); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Constructeur par recopie (clone) |
||||
|
*/ |
||||
|
Complex(const Complex & cpx); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Destructeur |
||||
|
*/ |
||||
|
~Complex(); |
||||
|
|
||||
|
/**
|
||||
|
* Retourne la partie réelle. |
||||
|
* |
||||
|
* @return la partie réelle du complexe |
||||
|
*/ |
||||
|
double getRealPart() const; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Retourne la partie imaginaire. |
||||
|
* |
||||
|
* @return la partie imaginaire du complexe |
||||
|
*/ |
||||
|
double getImaginaryPart() const; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Modifie la partie réelle |
||||
|
* |
||||
|
* @param re la nouvelle partie réelle affectée |
||||
|
*/ |
||||
|
void setRealPart(double re); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Modifie la partie imaginaire. |
||||
|
* |
||||
|
* @param im la nouvelle partie imaginaire affectée |
||||
|
*/ |
||||
|
void setImaginaryPart(double im); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Retourne le module. |
||||
|
* |
||||
|
* @return le module du nombre complexe |
||||
|
*/ |
||||
|
double getMagnitude() const; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Retourne l'argument en radians |
||||
|
* |
||||
|
* return l'argument du nombre complexe |
||||
|
*/ |
||||
|
double getAngle() const; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Retourne un nouveau complexe résultant de la rotation |
||||
|
* de l'instance de complexe par l'angle donné |
||||
|
* |
||||
|
* @param c centre de rotation |
||||
|
* @param angle angle de rotation en radians |
||||
|
* @return le resultat de la rotation |
||||
|
*/ |
||||
|
Complex rotate(Complex & c, double angle) const; |
||||
|
|
||||
|
/**
|
||||
|
* Donne une représentation sous la forme a + ib du nombre complexe |
||||
|
* et la copie dans le flux passé en argument |
||||
|
* |
||||
|
* @param output le flux dans lequel sera écrit la représentation |
||||
|
*/ |
||||
|
void writeTo(std::ostream & output) const; |
||||
|
|
||||
|
/**
|
||||
|
* Effectue la somme de ce complexe et de celui passe en parametre. |
||||
|
* |
||||
|
* @param c2 le complexe a ajouter |
||||
|
* @return la somme des deux complexes |
||||
|
*/ |
||||
|
Complex operator+(const Complex & c2) const; |
||||
|
|
||||
|
/**
|
||||
|
* Effectue la difference de ce complexe et de celui passe en parametre. |
||||
|
* |
||||
|
* @param c2 le complexe a soustraire |
||||
|
* @return la difference des deux complexes |
||||
|
*/ |
||||
|
Complex operator-(const Complex & c2) const; |
||||
|
|
||||
|
/**
|
||||
|
* Effectue le produit de ce complexe et de celui passe en parametre. |
||||
|
* |
||||
|
* @param c2 le complexe a multiplier |
||||
|
* @return le produit des deux complexes |
||||
|
*/ |
||||
|
Complex operator*(const Complex & c2) const; |
||||
|
|
||||
|
/**
|
||||
|
* Operateur d'affectation |
||||
|
* |
||||
|
* @param c2 le complexe a affecter |
||||
|
* @return le complexe |
||||
|
*/ |
||||
|
Complex & operator=(const Complex & c2); |
||||
|
|
||||
|
/**
|
||||
|
* Echange les parties réelles et imaginaires |
||||
|
*/ |
||||
|
void swapRealAndImaginaryPart(); |
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/**
|
||||
|
* Partie entière du nombre complexe |
||||
|
*/ |
||||
|
double _re; |
||||
|
|
||||
|
/**
|
||||
|
* Partie imaginaire du nombre complexe |
||||
|
*/ |
||||
|
double _im; |
||||
|
|
||||
|
|
||||
|
|
||||
|
}; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Effectue le produit de deux nombres complexes. |
||||
|
* |
||||
|
* @param cpx1 premier complexe |
||||
|
* @param cpx1 second complexe |
||||
|
* @return un nombre complexe issu du produit |
||||
|
* des deux premiers. La propriété est transférée à l'appelant. |
||||
|
*/ |
||||
|
Complex product(const Complex & cpx1, const Complex & cpx2); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Effectue la somme de deux nombres complexes. |
||||
|
* |
||||
|
* @param cpx1 premier complexe |
||||
|
* @param cpx1 second complexe |
||||
|
* @return un nombre complexe issu de la somme |
||||
|
* des deux premiers. La propriété est transférée à l'appelant. |
||||
|
*/ |
||||
|
Complex sum(const Complex & cpx1, const Complex & cpx2); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Effectue la difference de deux nombres complexes |
||||
|
* |
||||
|
* @param cpx1 premier complexe |
||||
|
* @param cpx1 second complexe |
||||
|
* @return un nombre complexe issu de la difference |
||||
|
* des deux premiers (cpx1 - cpx2 => cpx3). |
||||
|
*/ |
||||
|
Complex minus(const Complex & cpx1, const Complex & cpx2); |
||||
|
|
||||
|
/**
|
||||
|
* Normalise un complexe. |
||||
|
* |
||||
|
* @param cpx le complexe a normaliser |
||||
|
* @return le complexe normalise |
||||
|
*/ |
||||
|
Complex normalize(Complex cpx); |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le complexe qui a le plus grand module. |
||||
|
* |
||||
|
* @param c1 le premier complexe |
||||
|
* @param c2 le deuxieme complexe |
||||
|
* @return le plus grand des deux. |
||||
|
*/ |
||||
|
Complex & getMax(Complex & c1, Complex & c2); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Remplit le tableau de n elements avec une suite de nombre |
||||
|
* complexes de 0 à n-1. |
||||
|
* |
||||
|
* @param n le nombre d'éléments dans le tableau |
||||
|
* @param tab le tableau |
||||
|
*/ |
||||
|
void remplirTableau(int n, Complex * tab); |
||||
|
|
||||
|
|
||||
|
#endif /* def __COMPLEXE_H__ */ |
||||
@ -0,0 +1,218 @@ |
|||||
|
|
||||
|
|
||||
|
Réponses aux questions posées |
||||
|
|
||||
|
|
||||
|
|
||||
|
1.2 - Effectivement, et heureusement, selon toute attente, le compilateur |
||||
|
détecte un eerreur et refuse la compilation lorsque l'on essaie d'atteindre |
||||
|
un champ privé à partir d'une fonction non membre: |
||||
|
|
||||
|
complex.h: Dans function « Complex minus(const Complex&, const Complex&) »: |
||||
|
complex.h:115: error: `double Complex::_re' is private |
||||
|
|
||||
|
|
||||
|
1.4 - Il est difficile d'ajouter un Constructeur prenant pour argument le |
||||
|
module et l'argument, ce constructeur aurait la meme "signature" que celui |
||||
|
prenant comme argument la partie reelle et la partie imaginaire. En effet |
||||
|
ces quatres parametres seraient vraisemblablement des doubles, et lors de la |
||||
|
compilation, le compilateur ne pourrait determiner, a l'aide du type des |
||||
|
arguments, quel constructeur était souhaité. |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
3.1 - Nous avons cree une methode normalize dont le prototype est le suivant : |
||||
|
|
||||
|
Complex normalize(Complex cpx); |
||||
|
|
||||
|
Comme le parametre cpx est passe par valeur, il est necessaire d'en effectuer |
||||
|
une copie sur la pile d'ou l'appel au constructeur de recopie avant l'appel à |
||||
|
la fonction. On peut noter que la copie est detruite lorsque la fonction se |
||||
|
termine. |
||||
|
|
||||
|
Ainsi pour le code suivant : |
||||
|
|
||||
|
Complex c; |
||||
|
|
||||
|
[...] |
||||
|
|
||||
|
std::cout << "Normalisation" << std::endl; |
||||
|
c = normalize(a); |
||||
|
std::cout << std::endl; |
||||
|
std::cout << "Fin de la normalisation" << std::endl; |
||||
|
|
||||
|
On obtient la trace suivante : |
||||
|
|
||||
|
(1) +++Complex[0xbfd23db0](0, 0) |
||||
|
(2) Normalisation |
||||
|
(3) rrrComplex[0xbfd23d90](1 + i * 1) |
||||
|
(4) La normalisation a commence |
||||
|
(5) +++Complex[0xbfd23da0](0.707107, 0.707107) |
||||
|
(6) ===Complex[0xbfd23da0](0.707107 + i * 0.707107) >> [0xbfd23db0](0 + i * 0) |
||||
|
(7) ---Complex[0xbfd23da0](0.707107 + i * 0.707107) |
||||
|
(8) ---Complex[0xbfd23d90](1 + i * 1) |
||||
|
(9) Fin de la normalisation |
||||
|
(10) ---Complex[0xbfd23db0](0.707107 + i * 0.707107) |
||||
|
|
||||
|
Etude de la trace d'execution : |
||||
|
1 - Declaration du complexe "c", et appel du constructeur par defaut. |
||||
|
2 - Avant appel a la fonction de normalisation. |
||||
|
3 - Appel du constructeur de recopie pour passer le complexe sur la pile. |
||||
|
4 - Dans la fonction de normalisation |
||||
|
5 - Creation d'un nouveau complexe local |
||||
|
6 - Affectation de la valeur de retour (complexe local) |
||||
|
dans la variable c (appartenant à l'appelant) |
||||
|
7 - Destruction du complexe local |
||||
|
8 - Destruction du complexe parametre |
||||
|
9 - Fonction de normalisation terminee |
||||
|
10 - Destruction du complexe "c" |
||||
|
|
||||
|
=> Remarque : |
||||
|
|
||||
|
On remarque qu'un appel au constructeur de recopie est effectue pour passer |
||||
|
le parametre sur la pile (initialisation d'une zone mémoire "brute"), mais |
||||
|
que c'est l'opérateur d'affectation qui est utilisé pour recopier la valeur |
||||
|
de retour (écrasement d'une zone mémoire déjà initialisée) |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
3.2 - Nous avons ajoute une methode dont le prototype est le suivant : |
||||
|
|
||||
|
Complex Complex::rotate(Complex & c, double angle) const; |
||||
|
|
||||
|
Ainsi, pour le code suivant : |
||||
|
|
||||
|
std::cout << "Rotation" << std::endl; |
||||
|
c = b.rotate(a, M_PI / 2); |
||||
|
c.writeTo(std::cout); |
||||
|
std::cout << std::endl; |
||||
|
std::cout << "Fin de la rotation" << std::endl; |
||||
|
|
||||
|
et la methode suivante : |
||||
|
|
||||
|
Complex Complex::rotate(Complex & c, double angle) const { |
||||
|
Complex tmp = (*this) - c; |
||||
|
Complex tmp2 = tmp * Complex(cos(angle), sin(angle)); |
||||
|
return tmp2 + c; |
||||
|
} |
||||
|
|
||||
|
On obtient la trace d'execution suivante : |
||||
|
|
||||
|
(1) +++Complex[0xbfd5ef00](0, 0) |
||||
|
(2) Rotation |
||||
|
(3) +++Complex[0xbfd5ee80](2, 3) |
||||
|
(4) +++Complex[0xbfd5ee60](6.12303e-17, 1) |
||||
|
(5) +++Complex[0xbfd5ee70](-3, 2) |
||||
|
(6) ---Complex[0xbfd5ee60](6.12303e-17 + i * 1) |
||||
|
(7) +++Complex[0xbfd5eee0](-2, 3) |
||||
|
(8) ---Complex[0xbfd5ee70](-3 + i * 2) |
||||
|
(9) ---Complex[0xbfd5ee80](2 + i * 3) |
||||
|
(10) ===Complex[0xbfd5eee0](-2 + i * 3) >> [0xbfd5ef00](0.707107 + i * 0.707107) |
||||
|
(11) ---Complex[0xbfd5eee0](-2 + i * 3) |
||||
|
(12) Fin de la rotation |
||||
|
(13) ---Complex[0xbfd5ef00](-2 + i * 3) |
||||
|
|
||||
|
Etude de la trace d'execution : |
||||
|
1 - Declaration du complexe "c", et appel du constructeur par defaut. |
||||
|
2 - Avant appel a la methode de rotation. |
||||
|
3 - Creation et initialisation de l'objet tmp |
||||
|
4 - Creation et initialisation du complexe Complex(cos(angle), sin(angle)) |
||||
|
5 - Creation et initialisation de tmp2 |
||||
|
6 - Destruction de Complex(cos(angle), sin(angle)) |
||||
|
7 - Creation et initialisation de tmp2 + c |
||||
|
8 - Destruction de tmp2 |
||||
|
9 - Destruction de tmp |
||||
|
10 - Recopie de la valeur de retour (tmp2 + c) dans "c" |
||||
|
11 - Destruction de la valeur de retour |
||||
|
12 - Apres appel a la methode de rotation. |
||||
|
13 - Destruction de "c" |
||||
|
|
||||
|
=> Remarque : |
||||
|
On remarque que lors d'un passage d'arguments par référence, le |
||||
|
constructeur par recopie n'est pas appellé, d'ou un gain de performance. |
||||
|
Il ne faut cependant pas oublier que l'objet passé par référence est |
||||
|
modifiable pas la méthode appellée, c'est pourquoi l'utilisation du mot |
||||
|
clé "const", lorsque cela est possible, est recommandée. |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
3.3 - Nous avons defini une fonction dont le prototype est le suivant : |
||||
|
|
||||
|
Complex & getMax(Complex & c1, Complex & c2) |
||||
|
|
||||
|
et nous avons obtenu les resultats suivants : |
||||
|
|
||||
|
Debut de 'Complex d = getMax(a, b)' |
||||
|
(1) rrrComplex[0xbfed1af0](3 + i * 4) |
||||
|
Fin de 'Complex d = getMax(a, b)' |
||||
|
|
||||
|
Debut de 'c = getMax(a, b)' |
||||
|
(2) ===Complex[0xbfed1b20](3 + i * 4) >> [0xbfed1b10](-2 + i * 3) |
||||
|
Fin de 'c = getMax(a, b)' |
||||
|
|
||||
|
On remarque que : |
||||
|
1 - Lors d'une initialisation à partir du résultat de la fonction, |
||||
|
c'est le constructeur par recopie qui est utilisé. |
||||
|
2 - Lors d'une affectation, c'est la méthode qui surcharge l'opérateur |
||||
|
d'affectation qui est appellée. |
||||
|
|
||||
|
|
||||
|
|
||||
|
3.4 - Comme l'énoncé n'est pas très clair, nous avons choisi de remplir le |
||||
|
tableau selon la méthode suivante : |
||||
|
|
||||
|
tab[i] = Complex(i, 0); |
||||
|
|
||||
|
On obtient la trace d'exécution suivante : |
||||
|
|
||||
|
Debut de l'initialisation du tableau (taille 10) |
||||
|
(1) +++Complex[0xbf80c330](0, 0) |
||||
|
+++Complex[0xbf80c340](0, 0) |
||||
|
+++Complex[0xbf80c350](0, 0) |
||||
|
+++Complex[0xbf80c360](0, 0) |
||||
|
+++Complex[0xbf80c370](0, 0) |
||||
|
+++Complex[0xbf80c380](0, 0) |
||||
|
+++Complex[0xbf80c390](0, 0) |
||||
|
+++Complex[0xbf80c3a0](0, 0) |
||||
|
+++Complex[0xbf80c3b0](0, 0) |
||||
|
(10) +++Complex[0xbf80c3c0](0, 0) |
||||
|
Fin de l'initialisation du tableau |
||||
|
|
||||
|
Appel de la fonction remplirTableau(3, tab) |
||||
|
(11) +++Complex[0xbf80c2b0](0, 0) |
||||
|
(12) ===Complex[0xbf80c2b0](0 + i * 0) >> [0xbf80c330](0 + i * 0) |
||||
|
(13) ---Complex[0xbf80c2b0](0 + i * 0) |
||||
|
+++Complex[0xbf80c2b0](1, 0) |
||||
|
===Complex[0xbf80c2b0](1 + i * 0) >> [0xbf80c340](0 + i * 0) |
||||
|
---Complex[0xbf80c2b0](1 + i * 0) |
||||
|
+++Complex[0xbf80c2b0](2, 0) |
||||
|
===Complex[0xbf80c2b0](2 + i * 0) >> [0xbf80c350](0 + i * 0) |
||||
|
---Complex[0xbf80c2b0](2 + i * 0) |
||||
|
Fin de l'appel |
||||
|
|
||||
|
(14) ---Complex[0xbf80c3c0](0 + i * 0) |
||||
|
---Complex[0xbf80c3b0](0 + i * 0) |
||||
|
---Complex[0xbf80c3a0](0 + i * 0) |
||||
|
---Complex[0xbf80c390](0 + i * 0) |
||||
|
---Complex[0xbf80c380](0 + i * 0) |
||||
|
---Complex[0xbf80c370](0 + i * 0) |
||||
|
---Complex[0xbf80c360](0 + i * 0) |
||||
|
---Complex[0xbf80c350](2 + i * 0) |
||||
|
---Complex[0xbf80c340](1 + i * 0) |
||||
|
(24) ---Complex[0xbf80c330](0 + i * 0) |
||||
|
|
||||
|
|
||||
|
Remarques : |
||||
|
1-10 - Chaque element du tableau est initialisé par le constructeur par |
||||
|
defaut. |
||||
|
|
||||
|
11 - Un objet temporaire est cree. |
||||
|
12 - Cet objet est affecté a la case courante du tableau. |
||||
|
13 - L'objet temporaire est detruit. |
||||
|
|
||||
|
14-24 - Chaque element du tableau est passé au destructeur. |
||||
|
|
||||
|
|
||||
@ -0,0 +1,101 @@ |
|||||
|
<?xml version = '1.0'?> |
||||
|
<kdevelop> |
||||
|
<general> |
||||
|
<author>Nicolas MASSE</author> |
||||
|
<email>nicolas27.masse@laposte.net</email> |
||||
|
<version>$VERSION$</version> |
||||
|
<projectmanagement>KDevCustomProject</projectmanagement> |
||||
|
<primarylanguage>C++</primarylanguage> |
||||
|
<ignoreparts/> |
||||
|
</general> |
||||
|
<kdevcustomproject> |
||||
|
<run> |
||||
|
<mainprogram>CalculMatriciel</mainprogram> |
||||
|
<directoryradio>executable</directoryradio> |
||||
|
</run> |
||||
|
</kdevcustomproject> |
||||
|
<kdevdebugger> |
||||
|
<general> |
||||
|
<dbgshell/> |
||||
|
</general> |
||||
|
</kdevdebugger> |
||||
|
<kdevdoctreeview> |
||||
|
<ignoretocs> |
||||
|
<toc>ada</toc> |
||||
|
<toc>ada_bugs_gcc</toc> |
||||
|
<toc>bash</toc> |
||||
|
<toc>bash_bugs</toc> |
||||
|
<toc>clanlib</toc> |
||||
|
<toc>fortran_bugs_gcc</toc> |
||||
|
<toc>gnome1</toc> |
||||
|
<toc>gnustep</toc> |
||||
|
<toc>gtk</toc> |
||||
|
<toc>gtk_bugs</toc> |
||||
|
<toc>haskell</toc> |
||||
|
<toc>haskell_bugs_ghc</toc> |
||||
|
<toc>java_bugs_gcc</toc> |
||||
|
<toc>java_bugs_sun</toc> |
||||
|
<toc>kde2book</toc> |
||||
|
<toc>opengl</toc> |
||||
|
<toc>pascal_bugs_fp</toc> |
||||
|
<toc>php</toc> |
||||
|
<toc>php_bugs</toc> |
||||
|
<toc>perl</toc> |
||||
|
<toc>perl_bugs</toc> |
||||
|
<toc>python</toc> |
||||
|
<toc>python_bugs</toc> |
||||
|
<toc>qt-kdev3</toc> |
||||
|
<toc>ruby</toc> |
||||
|
<toc>ruby_bugs</toc> |
||||
|
<toc>sdl</toc> |
||||
|
<toc>sw</toc> |
||||
|
<toc>w3c-dom-level2-html</toc> |
||||
|
<toc>w3c-svg</toc> |
||||
|
<toc>w3c-uaag10</toc> |
||||
|
<toc>wxwidgets_bugs</toc> |
||||
|
</ignoretocs> |
||||
|
<ignoreqt_xml> |
||||
|
<toc>Guide to the Qt Translation Tools</toc> |
||||
|
<toc>Qt Assistant Manual</toc> |
||||
|
<toc>Qt Designer Manual</toc> |
||||
|
<toc>Qt Reference Documentation</toc> |
||||
|
<toc>qmake User Guide</toc> |
||||
|
</ignoreqt_xml> |
||||
|
<ignoredoxygen> |
||||
|
<toc>KDE Libraries (Doxygen)</toc> |
||||
|
</ignoredoxygen> |
||||
|
</kdevdoctreeview> |
||||
|
<kdevfilecreate> |
||||
|
<filetypes/> |
||||
|
<useglobaltypes> |
||||
|
<type ext="ui" /> |
||||
|
<type ext="cpp" /> |
||||
|
<type ext="h" /> |
||||
|
</useglobaltypes> |
||||
|
</kdevfilecreate> |
||||
|
<kdevcppsupport> |
||||
|
<references/> |
||||
|
<codecompletion> |
||||
|
<includeGlobalFunctions>true</includeGlobalFunctions> |
||||
|
<includeTypes>true</includeTypes> |
||||
|
<includeEnums>true</includeEnums> |
||||
|
<includeTypedefs>false</includeTypedefs> |
||||
|
<automaticCodeCompletion>true</automaticCodeCompletion> |
||||
|
<automaticArgumentsHint>true</automaticArgumentsHint> |
||||
|
<automaticHeaderCompletion>true</automaticHeaderCompletion> |
||||
|
<codeCompletionDelay>250</codeCompletionDelay> |
||||
|
<argumentsHintDelay>400</argumentsHintDelay> |
||||
|
<headerCompletionDelay>250</headerCompletionDelay> |
||||
|
</codecompletion> |
||||
|
</kdevcppsupport> |
||||
|
<kdevfileview> |
||||
|
<groups> |
||||
|
<hidenonprojectfiles>false</hidenonprojectfiles> |
||||
|
<hidenonlocation>false</hidenonlocation> |
||||
|
</groups> |
||||
|
<tree> |
||||
|
<hidepatterns>*.o,*.lo,CVS</hidepatterns> |
||||
|
<hidenonprojectfiles>false</hidenonprojectfiles> |
||||
|
</tree> |
||||
|
</kdevfileview> |
||||
|
</kdevelop> |
||||
@ -0,0 +1,5 @@ |
|||||
|
# KDevelop Custom Project File List |
||||
|
checkMatrix.cpp |
||||
|
Makefile |
||||
|
matrix.cpp |
||||
|
matrix.h |
||||
Binary file not shown.
@ -0,0 +1,32 @@ |
|||||
|
<?xml version = '1.0' encoding = 'UTF-8'?> |
||||
|
<!DOCTYPE KDevPrjSession> |
||||
|
<KDevPrjSession> |
||||
|
<DocsAndViews NumberOfDocuments="4" > |
||||
|
<Doc0 NumberOfViews="1" URL="file:///home/nicolas/repository/ENSI_2ndY/Cpp/TP3_12-10-2005_CalculMatriciel/checkMatrix.cpp" > |
||||
|
<View0 Type="Source" /> |
||||
|
</Doc0> |
||||
|
<Doc1 NumberOfViews="1" URL="file:///home/nicolas/repository/ENSI_2ndY/Cpp/TP3_12-10-2005_CalculMatriciel/matrix.h" > |
||||
|
<View0 line="126" Type="Source" /> |
||||
|
</Doc1> |
||||
|
<Doc2 NumberOfViews="1" URL="file:///home/nicolas/repository/ENSI_2ndY/Cpp/TP3_12-10-2005_CalculMatriciel/matrix.cpp" > |
||||
|
<View0 line="231" Type="Source" /> |
||||
|
</Doc2> |
||||
|
<Doc3 NumberOfViews="1" URL="file:///home/nicolas/repository/ENSI_2ndY/Cpp/TP3_12-10-2005_CalculMatriciel/Makefile" > |
||||
|
<View0 line="20" Type="Source" /> |
||||
|
</Doc3> |
||||
|
</DocsAndViews> |
||||
|
<pluginList> |
||||
|
<kdevdebugger> |
||||
|
<breakpointList/> |
||||
|
</kdevdebugger> |
||||
|
<kdevbookmarks> |
||||
|
<bookmarks/> |
||||
|
</kdevbookmarks> |
||||
|
<kdevvalgrind> |
||||
|
<executable path="" params="" /> |
||||
|
<valgrind path="" params="" /> |
||||
|
<calltree path="" params="" /> |
||||
|
<kcachegrind path="" /> |
||||
|
</kdevvalgrind> |
||||
|
</pluginList> |
||||
|
</KDevPrjSession> |
||||
@ -0,0 +1,275 @@ |
|||||
|
# Doxyfile 1.4.1-KDevelop |
||||
|
|
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Project related configuration options |
||||
|
#--------------------------------------------------------------------------- |
||||
|
PROJECT_NAME = CalculMatriciel.kdevelop |
||||
|
PROJECT_NUMBER = $VERSION$ |
||||
|
OUTPUT_DIRECTORY = |
||||
|
CREATE_SUBDIRS = NO |
||||
|
OUTPUT_LANGUAGE = English |
||||
|
USE_WINDOWS_ENCODING = NO |
||||
|
BRIEF_MEMBER_DESC = YES |
||||
|
REPEAT_BRIEF = YES |
||||
|
ABBREVIATE_BRIEF = "The $name class" \ |
||||
|
"The $name widget" \ |
||||
|
"The $name file" \ |
||||
|
is \ |
||||
|
provides \ |
||||
|
specifies \ |
||||
|
contains \ |
||||
|
represents \ |
||||
|
a \ |
||||
|
an \ |
||||
|
the |
||||
|
ALWAYS_DETAILED_SEC = NO |
||||
|
INLINE_INHERITED_MEMB = NO |
||||
|
FULL_PATH_NAMES = YES |
||||
|
STRIP_FROM_PATH = /home/nicolas/ |
||||
|
STRIP_FROM_INC_PATH = |
||||
|
SHORT_NAMES = NO |
||||
|
JAVADOC_AUTOBRIEF = NO |
||||
|
MULTILINE_CPP_IS_BRIEF = NO |
||||
|
DETAILS_AT_TOP = NO |
||||
|
INHERIT_DOCS = YES |
||||
|
DISTRIBUTE_GROUP_DOC = NO |
||||
|
TAB_SIZE = 8 |
||||
|
ALIASES = |
||||
|
OPTIMIZE_OUTPUT_FOR_C = NO |
||||
|
OPTIMIZE_OUTPUT_JAVA = NO |
||||
|
SUBGROUPING = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Build related configuration options |
||||
|
#--------------------------------------------------------------------------- |
||||
|
EXTRACT_ALL = NO |
||||
|
EXTRACT_PRIVATE = NO |
||||
|
EXTRACT_STATIC = NO |
||||
|
EXTRACT_LOCAL_CLASSES = YES |
||||
|
EXTRACT_LOCAL_METHODS = NO |
||||
|
HIDE_UNDOC_MEMBERS = NO |
||||
|
HIDE_UNDOC_CLASSES = NO |
||||
|
HIDE_FRIEND_COMPOUNDS = NO |
||||
|
HIDE_IN_BODY_DOCS = NO |
||||
|
INTERNAL_DOCS = NO |
||||
|
CASE_SENSE_NAMES = YES |
||||
|
HIDE_SCOPE_NAMES = NO |
||||
|
SHOW_INCLUDE_FILES = YES |
||||
|
INLINE_INFO = YES |
||||
|
SORT_MEMBER_DOCS = YES |
||||
|
SORT_BRIEF_DOCS = NO |
||||
|
SORT_BY_SCOPE_NAME = NO |
||||
|
GENERATE_TODOLIST = YES |
||||
|
GENERATE_TESTLIST = YES |
||||
|
GENERATE_BUGLIST = YES |
||||
|
GENERATE_DEPRECATEDLIST= YES |
||||
|
ENABLED_SECTIONS = |
||||
|
MAX_INITIALIZER_LINES = 30 |
||||
|
SHOW_USED_FILES = YES |
||||
|
SHOW_DIRECTORIES = YES |
||||
|
FILE_VERSION_FILTER = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to warning and progress messages |
||||
|
#--------------------------------------------------------------------------- |
||||
|
QUIET = NO |
||||
|
WARNINGS = YES |
||||
|
WARN_IF_UNDOCUMENTED = YES |
||||
|
WARN_IF_DOC_ERROR = YES |
||||
|
WARN_NO_PARAMDOC = NO |
||||
|
WARN_FORMAT = "$file:$line: $text" |
||||
|
WARN_LOGFILE = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the input files |
||||
|
#--------------------------------------------------------------------------- |
||||
|
INPUT = /home/nicolas/repository/ENSI_2ndY/Cpp/TP3_12-10-2005_CalculMatriciel |
||||
|
FILE_PATTERNS = *.c \ |
||||
|
*.cc \ |
||||
|
*.cxx \ |
||||
|
*.cpp \ |
||||
|
*.c++ \ |
||||
|
*.java \ |
||||
|
*.ii \ |
||||
|
*.ixx \ |
||||
|
*.ipp \ |
||||
|
*.i++ \ |
||||
|
*.inl \ |
||||
|
*.h \ |
||||
|
*.hh \ |
||||
|
*.hxx \ |
||||
|
*.hpp \ |
||||
|
*.h++ \ |
||||
|
*.idl \ |
||||
|
*.odl \ |
||||
|
*.cs \ |
||||
|
*.php \ |
||||
|
*.php3 \ |
||||
|
*.inc \ |
||||
|
*.m \ |
||||
|
*.mm \ |
||||
|
*.dox \ |
||||
|
*.C \ |
||||
|
*.CC \ |
||||
|
*.C++ \ |
||||
|
*.II \ |
||||
|
*.I++ \ |
||||
|
*.H \ |
||||
|
*.HH \ |
||||
|
*.H++ \ |
||||
|
*.CS \ |
||||
|
*.PHP \ |
||||
|
*.PHP3 \ |
||||
|
*.M \ |
||||
|
*.MM \ |
||||
|
*.C \ |
||||
|
*.H \ |
||||
|
*.tlh \ |
||||
|
*.diff \ |
||||
|
*.patch \ |
||||
|
*.moc \ |
||||
|
*.xpm \ |
||||
|
*.dox |
||||
|
RECURSIVE = yes |
||||
|
EXCLUDE = |
||||
|
EXCLUDE_SYMLINKS = NO |
||||
|
EXCLUDE_PATTERNS = |
||||
|
EXAMPLE_PATH = |
||||
|
EXAMPLE_PATTERNS = * |
||||
|
EXAMPLE_RECURSIVE = NO |
||||
|
IMAGE_PATH = |
||||
|
INPUT_FILTER = |
||||
|
FILTER_PATTERNS = |
||||
|
FILTER_SOURCE_FILES = NO |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to source browsing |
||||
|
#--------------------------------------------------------------------------- |
||||
|
SOURCE_BROWSER = NO |
||||
|
INLINE_SOURCES = NO |
||||
|
STRIP_CODE_COMMENTS = YES |
||||
|
REFERENCED_BY_RELATION = YES |
||||
|
REFERENCES_RELATION = YES |
||||
|
VERBATIM_HEADERS = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the alphabetical class index |
||||
|
#--------------------------------------------------------------------------- |
||||
|
ALPHABETICAL_INDEX = NO |
||||
|
COLS_IN_ALPHA_INDEX = 5 |
||||
|
IGNORE_PREFIX = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the HTML output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_HTML = YES |
||||
|
HTML_OUTPUT = html |
||||
|
HTML_FILE_EXTENSION = .html |
||||
|
HTML_HEADER = |
||||
|
HTML_FOOTER = |
||||
|
HTML_STYLESHEET = |
||||
|
HTML_ALIGN_MEMBERS = YES |
||||
|
GENERATE_HTMLHELP = NO |
||||
|
CHM_FILE = |
||||
|
HHC_LOCATION = |
||||
|
GENERATE_CHI = NO |
||||
|
BINARY_TOC = NO |
||||
|
TOC_EXPAND = NO |
||||
|
DISABLE_INDEX = NO |
||||
|
ENUM_VALUES_PER_LINE = 4 |
||||
|
GENERATE_TREEVIEW = NO |
||||
|
TREEVIEW_WIDTH = 250 |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the LaTeX output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_LATEX = YES |
||||
|
LATEX_OUTPUT = latex |
||||
|
LATEX_CMD_NAME = latex |
||||
|
MAKEINDEX_CMD_NAME = makeindex |
||||
|
COMPACT_LATEX = NO |
||||
|
PAPER_TYPE = a4wide |
||||
|
EXTRA_PACKAGES = |
||||
|
LATEX_HEADER = |
||||
|
PDF_HYPERLINKS = NO |
||||
|
USE_PDFLATEX = NO |
||||
|
LATEX_BATCHMODE = NO |
||||
|
LATEX_HIDE_INDICES = NO |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the RTF output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_RTF = NO |
||||
|
RTF_OUTPUT = rtf |
||||
|
COMPACT_RTF = NO |
||||
|
RTF_HYPERLINKS = NO |
||||
|
RTF_STYLESHEET_FILE = |
||||
|
RTF_EXTENSIONS_FILE = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the man page output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_MAN = NO |
||||
|
MAN_OUTPUT = man |
||||
|
MAN_EXTENSION = .3 |
||||
|
MAN_LINKS = NO |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the XML output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_XML = yes |
||||
|
XML_OUTPUT = xml |
||||
|
XML_SCHEMA = |
||||
|
XML_DTD = |
||||
|
XML_PROGRAMLISTING = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options for the AutoGen Definitions output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_AUTOGEN_DEF = NO |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the Perl module output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_PERLMOD = NO |
||||
|
PERLMOD_LATEX = NO |
||||
|
PERLMOD_PRETTY = YES |
||||
|
PERLMOD_MAKEVAR_PREFIX = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Configuration options related to the preprocessor |
||||
|
#--------------------------------------------------------------------------- |
||||
|
ENABLE_PREPROCESSING = YES |
||||
|
MACRO_EXPANSION = NO |
||||
|
EXPAND_ONLY_PREDEF = NO |
||||
|
SEARCH_INCLUDES = YES |
||||
|
INCLUDE_PATH = |
||||
|
INCLUDE_FILE_PATTERNS = |
||||
|
PREDEFINED = |
||||
|
EXPAND_AS_DEFINED = |
||||
|
SKIP_FUNCTION_MACROS = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Configuration::additions related to external references |
||||
|
#--------------------------------------------------------------------------- |
||||
|
TAGFILES = |
||||
|
GENERATE_TAGFILE = CalculMatriciel.tag |
||||
|
ALLEXTERNALS = NO |
||||
|
EXTERNAL_GROUPS = YES |
||||
|
PERL_PATH = /usr/bin/perl |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Configuration options related to the dot tool |
||||
|
#--------------------------------------------------------------------------- |
||||
|
CLASS_DIAGRAMS = YES |
||||
|
HIDE_UNDOC_RELATIONS = YES |
||||
|
HAVE_DOT = NO |
||||
|
CLASS_GRAPH = YES |
||||
|
COLLABORATION_GRAPH = YES |
||||
|
GROUP_GRAPHS = YES |
||||
|
UML_LOOK = NO |
||||
|
TEMPLATE_RELATIONS = NO |
||||
|
INCLUDE_GRAPH = YES |
||||
|
INCLUDED_BY_GRAPH = YES |
||||
|
CALL_GRAPH = NO |
||||
|
GRAPHICAL_HIERARCHY = YES |
||||
|
DIRECTORY_GRAPH = YES |
||||
|
DOT_IMAGE_FORMAT = png |
||||
|
DOT_PATH = |
||||
|
DOTFILE_DIRS = |
||||
|
MAX_DOT_GRAPH_WIDTH = 1024 |
||||
|
MAX_DOT_GRAPH_HEIGHT = 1024 |
||||
|
MAX_DOT_GRAPH_DEPTH = 1000 |
||||
|
DOT_TRANSPARENT = NO |
||||
|
DOT_MULTI_TARGETS = NO |
||||
|
GENERATE_LEGEND = YES |
||||
|
DOT_CLEANUP = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Configuration::additions related to the search engine |
||||
|
#--------------------------------------------------------------------------- |
||||
|
SEARCHENGINE = NO |
||||
@ -0,0 +1,49 @@ |
|||||
|
#
|
||||
|
# Makefile ENSICAEN 2005
|
||||
|
#
|
||||
|
# MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net>
|
||||
|
# LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net>
|
||||
|
#
|
||||
|
# ENSICAEN
|
||||
|
# 6 Boulevard Marechal Juin
|
||||
|
# F-14050 Caen Cedex
|
||||
|
#
|
||||
|
# Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre
|
||||
|
# reproduit, utilise ou modifie sans l'avis express de ses auteurs.
|
||||
|
#
|
||||
|
|
||||
|
#
|
||||
|
# Description du makefile
|
||||
|
#
|
||||
|
|
||||
|
CXX = g++ |
||||
|
LD = g++ |
||||
|
CFLAGS = -Wall --pedantic -ggdb |
||||
|
CPPFLAGS = -I./ |
||||
|
|
||||
|
|
||||
|
OBJECTS = matrix.o |
||||
|
|
||||
|
EXEC = checkMatrix |
||||
|
|
||||
|
checkMatrix : checkMatrix.o |
||||
|
|
||||
|
all : $(OBJECTS) |
||||
|
|
||||
|
checkMatrix.o : %.o : %.cpp |
||||
|
$(CXX) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
||||
|
|
||||
|
$(OBJECTS) : %.o : %.cpp %.h |
||||
|
$(CXX) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
||||
|
|
||||
|
$(EXEC) : % : %.o $(OBJECTS) |
||||
|
$(LD) $^ -o $@ |
||||
|
|
||||
|
clean: |
||||
|
rm -f *~ *.o |
||||
|
|
||||
|
distclean: clean |
||||
|
rm -f $(EXEC) |
||||
|
|
||||
|
.PHONY: all clean distclean |
||||
|
|
||||
@ -0,0 +1,92 @@ |
|||||
|
/**
|
||||
|
* #(@)checkMatrix.cpp ENSICAEN 2005-10-18 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Test de la classe Matrix, objet du TP3 |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
#include "matrix.h" |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
int main(int argc, char ** argv) { |
||||
|
unsigned int truc; |
||||
|
|
||||
|
cout << "isPowerOfTwo(0) = " << isPowerOfTwo(0, &truc) << " (" << truc << ")" << endl; |
||||
|
cout << "isPowerOfTwo(1) = " << isPowerOfTwo(1, &truc) << " (" << truc << ")" << endl; |
||||
|
cout << "isPowerOfTwo(2) = " << isPowerOfTwo(2, &truc) << " (" << truc << ")" << endl; |
||||
|
cout << "isPowerOfTwo(3) = " << isPowerOfTwo(3, &truc) << " (" << truc << ")" << endl; |
||||
|
cout << "isPowerOfTwo(4) = " << isPowerOfTwo(4, &truc) << " (" << truc << ")" << endl; |
||||
|
cout << "isPowerOfTwo(5) = " << isPowerOfTwo(5, &truc) << " (" << truc << ")" << endl; |
||||
|
cout << "isPowerOfTwo(6) = " << isPowerOfTwo(6, &truc) << " (" << truc << ")" << endl; |
||||
|
cout << "isPowerOfTwo(7) = " << isPowerOfTwo(7, &truc) << " (" << truc << ")" << endl; |
||||
|
cout << "isPowerOfTwo(0x80000000) = " << isPowerOfTwo(0x80000000, &truc) << " (" << truc << ")" << endl; |
||||
|
|
||||
|
|
||||
|
Matrix a(1,2); |
||||
|
Matrix b; |
||||
|
// Matrix * c;
|
||||
|
|
||||
|
bool result = a == b; |
||||
|
|
||||
|
cout << "a == b ? " << result << endl; |
||||
|
|
||||
|
Matrix d(2, 3); |
||||
|
Matrix e(3, 3); |
||||
|
|
||||
|
d.setValueAt(1, 1, 11); |
||||
|
d.setValueAt(1, 2, 12); |
||||
|
d.setValueAt(1, 3, 13); |
||||
|
d.setValueAt(2, 1, 21); |
||||
|
d.setValueAt(2, 2, 22); |
||||
|
d.setValueAt(2, 3, 23); |
||||
|
|
||||
|
e.setValueAt(1, 1, 1); |
||||
|
e.setValueAt(2, 2, 1); |
||||
|
e.setValueAt(3, 3, 1); |
||||
|
|
||||
|
Matrix f = d * e; |
||||
|
cout << d << e; |
||||
|
cout << f; |
||||
|
|
||||
|
//Matrix q(1,1);
|
||||
|
//q.setValueAt(1, 1, 4);
|
||||
|
|
||||
|
Matrix q(2,2); |
||||
|
q.setValueAt(1, 1, 1); |
||||
|
q.setValueAt(1, 2, 2); |
||||
|
q.setValueAt(2, 1, 3); |
||||
|
q.setValueAt(2, 2, 4); |
||||
|
|
||||
|
//for (unsigned int i = 1; i <= q.getLineNb(); i++) {
|
||||
|
// for (unsigned int j = 1; j <= q.getColNb(); j++) {
|
||||
|
// q.setValueAt(i, j, (i * j) % 7);
|
||||
|
// }
|
||||
|
//}
|
||||
|
|
||||
|
Matrix iq = q.invert(); |
||||
|
cout << "Avant l'inversion:" << endl << q << endl; |
||||
|
cout << "Résultat de l'inversion:" << endl << iq << endl; |
||||
|
/*
|
||||
|
cout << "Entrez une matrice au clavier, dont le format est le suivant :" << endl; |
||||
|
cout << "nlignes ncols 11 12 13 21 22 23 ..." << endl; |
||||
|
|
||||
|
cin >> &c; |
||||
|
|
||||
|
cout << *c; |
||||
|
|
||||
|
delete c; |
||||
|
*/ |
||||
|
} |
||||
@ -0,0 +1,489 @@ |
|||||
|
/**
|
||||
|
* #(@)matrix.cpp ENSICAEN 2005-10-15 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
#include "matrix.h" |
||||
|
|
||||
|
Matrix::Matrix(unsigned int line_nb, unsigned int col_nb) { |
||||
|
// store dimensions
|
||||
|
_line_nb = line_nb; |
||||
|
_col_nb = col_nb; |
||||
|
|
||||
|
// allocate memory
|
||||
|
_columns = new double[line_nb * col_nb]; |
||||
|
_lines = new double*[line_nb]; |
||||
|
|
||||
|
// initialise lines' pointers
|
||||
|
for (unsigned int i = 0; i < line_nb; i++) { |
||||
|
_lines[i] = _columns + (i * col_nb); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Matrix::Matrix(const Matrix & m) { |
||||
|
// retrieve and copy dimension
|
||||
|
_line_nb = m._line_nb; |
||||
|
_col_nb = m._col_nb; |
||||
|
|
||||
|
// allocate memory
|
||||
|
_columns = new double[_line_nb * _col_nb]; |
||||
|
_lines = new double*[_line_nb]; |
||||
|
|
||||
|
|
||||
|
// initialise lines' pointers
|
||||
|
for (unsigned int i = 0; i < _line_nb; i++) { |
||||
|
_lines[i] = _columns + (i * _col_nb); |
||||
|
} |
||||
|
|
||||
|
// copy the values from m to this
|
||||
|
double * src = m._columns; |
||||
|
double * dest = _columns; |
||||
|
for (unsigned int i = _line_nb * _col_nb; i > 0 ; i--) { |
||||
|
*(dest++) = *(src++); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
Matrix::~Matrix() { |
||||
|
// free the two blocks of memory
|
||||
|
delete[] _lines; |
||||
|
delete[] _columns; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Matrix & Matrix::operator=(const Matrix & m) { |
||||
|
// check inequality
|
||||
|
if (this != &m) { |
||||
|
|
||||
|
// matrix geometry changed flag
|
||||
|
bool reInitLines = false; |
||||
|
|
||||
|
// check number of coefficients
|
||||
|
unsigned int nbCells = (m._col_nb * m._line_nb); |
||||
|
if ((_col_nb * _line_nb) != nbCells) { |
||||
|
// number of "cells" has changed : necessary to reallocate memory
|
||||
|
delete[] _columns; |
||||
|
_columns = new double[_line_nb * _col_nb]; |
||||
|
reInitLines = true; |
||||
|
} |
||||
|
|
||||
|
// check number of line:
|
||||
|
if (_line_nb != m._line_nb) { |
||||
|
// number of line has changed : necessary to reallocate memory
|
||||
|
delete[] _lines; |
||||
|
_lines = new double*[_line_nb]; |
||||
|
reInitLines = true; |
||||
|
} |
||||
|
|
||||
|
// store new dimensions
|
||||
|
_line_nb = m._line_nb; |
||||
|
_col_nb = m._col_nb; |
||||
|
|
||||
|
if (reInitLines) { |
||||
|
// initialise lines' pointers
|
||||
|
for (unsigned int i = 0; i < _line_nb; i++) { |
||||
|
_lines[i] = _columns + (i * _col_nb); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// copy the values from m to this
|
||||
|
double * src = m._columns; |
||||
|
double * dest = _columns; |
||||
|
for (unsigned int i = nbCells; i > 0 ; i--) { |
||||
|
*(dest++) = *(src++); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return *this; |
||||
|
} |
||||
|
|
||||
|
bool Matrix::operator==(const Matrix & m) const { |
||||
|
|
||||
|
// check dimensions
|
||||
|
if ((_line_nb != m._line_nb) || (_col_nb != m._col_nb)) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
// check coefficients values
|
||||
|
double * c1 = m._columns; |
||||
|
double * c2 = _columns; |
||||
|
for (unsigned int i = _line_nb * _col_nb; i > 0 ; i--) { |
||||
|
if (*(c1++) != *(c2++)) { |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool Matrix::operator!=(const Matrix & m) const { |
||||
|
return ! (*this == m); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Matrix Matrix::operator+(const Matrix & m) const { |
||||
|
Matrix mat(*this); |
||||
|
|
||||
|
mat += m; |
||||
|
|
||||
|
return mat; |
||||
|
} |
||||
|
|
||||
|
Matrix & Matrix::operator+=(const Matrix & m) { |
||||
|
assert(m.getColNb() == this->getColNb()); |
||||
|
assert(m.getLineNb() == this->getLineNb()); |
||||
|
|
||||
|
for (unsigned int r = 1; r <= this->getLineNb(); r++) { |
||||
|
for (unsigned int c = 1; c <= this->getColNb(); c++) { |
||||
|
this->setValueAt(r, c, this->getValueAt(r, c) + m.getValueAt(r, c)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return *this; |
||||
|
} |
||||
|
|
||||
|
Matrix Matrix::operator-(const Matrix & m) const { |
||||
|
Matrix mat(*this); |
||||
|
|
||||
|
mat -= m; |
||||
|
|
||||
|
return mat; |
||||
|
} |
||||
|
|
||||
|
Matrix & Matrix::operator-=(const Matrix & m) { |
||||
|
assert(m.getColNb() == this->getColNb()); |
||||
|
assert(m.getLineNb() == this->getLineNb()); |
||||
|
|
||||
|
for (unsigned int r = 1; r <= this->getLineNb(); r++) { |
||||
|
for (unsigned int c = 1; c <= this->getColNb(); c++) { |
||||
|
this->setValueAt(r, c, this->getValueAt(r, c) - m.getValueAt(r, c)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return *this; |
||||
|
} |
||||
|
|
||||
|
Matrix Matrix::operator-() const { |
||||
|
Matrix tmp(this->getLineNb(), this->getColNb()); |
||||
|
|
||||
|
for (unsigned int r = 1; r <= this->getLineNb(); r++) { |
||||
|
for (unsigned int c = 1; c <= this->getColNb(); c++) { |
||||
|
tmp.setValueAt(r, c, - this->getValueAt(r, c)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return tmp; |
||||
|
} |
||||
|
|
||||
|
Matrix Matrix::transpose() const { |
||||
|
Matrix mat(this->getColNb(), this->getLineNb()); |
||||
|
|
||||
|
for (unsigned int r = 1; r <= this->getLineNb(); r++) { |
||||
|
for (unsigned int c = 1; c <= this->getColNb(); c++) { |
||||
|
mat.setValueAt(c, r, this->getValueAt(r, c)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return mat; |
||||
|
} |
||||
|
|
||||
|
Matrix Matrix::invertR() const { |
||||
|
assert(this->getColNb() == this->getLineNb() && isPowerOfTwo(this->getColNb(), 0)); |
||||
|
|
||||
|
if (this->getColNb() == 1) { |
||||
|
Matrix tmp(1, 1); |
||||
|
tmp.setValueAt(1, 1, 1 / this->getValueAt(1, 1)); |
||||
|
cout << "Résultat temporaire:" << endl << *this << endl << tmp << endl; |
||||
|
return tmp; |
||||
|
} else { |
||||
|
Matrix B = this->getQuarter(1); |
||||
|
Matrix Ct = this->getQuarter(2); |
||||
|
Matrix D = this->getQuarter(3); |
||||
|
Matrix C = this->getQuarter(4); |
||||
|
|
||||
|
cout << "quarter B" << endl << B << endl; |
||||
|
cout << "quarter Ct" << endl << Ct << endl; |
||||
|
cout << "quarter D" << endl << D << endl; |
||||
|
cout << "quarter C" << endl << C << endl; |
||||
|
|
||||
|
Matrix Bm1 = B.invertR(); |
||||
|
Matrix CBm1T = (C * Bm1).transpose(); |
||||
|
Matrix S = D - C * Bm1 * Ct; // OK
|
||||
|
Matrix Q3 = S.invertR(); |
||||
|
Matrix & Sm1 = Q3; |
||||
|
Matrix Sm1CBm1 = (Sm1 * C) * Bm1; |
||||
|
Matrix Sm1CBm1T = Sm1CBm1.transpose(); |
||||
|
|
||||
|
Matrix Bm1CTSm1 = (Bm1 * CBm1T) * Sm1; |
||||
|
Matrix Q2 = -Bm1CTSm1; |
||||
|
|
||||
|
Matrix Q4 = - Sm1CBm1; |
||||
|
|
||||
|
Matrix Q1 = Bm1 + (CBm1T * Sm1CBm1); |
||||
|
|
||||
|
Matrix ret(this->getLineNb(), this->getLineNb()); |
||||
|
|
||||
|
unsigned int nl1 = Q1.getLineNb(); |
||||
|
unsigned int nc1 = Q1.getColNb(); |
||||
|
for (unsigned int i = 1; i <= nl1; i ++) { |
||||
|
for (unsigned int j = 1; j <= nc1; j ++) { |
||||
|
ret.setValueAt(i,j, Q1.getValueAt(i, j)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
unsigned int nl2 = Q2.getLineNb(); |
||||
|
unsigned int nc2 = Q2.getColNb(); |
||||
|
for (unsigned int i = 1; i <= nl2; i ++) { |
||||
|
for (unsigned int j = 1; j <= nc2; j ++) { |
||||
|
ret.setValueAt(i, nc1 + j, Q2.getValueAt(i, j)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
unsigned int nl3 = Q3.getLineNb(); |
||||
|
unsigned int nc3 = Q3.getColNb(); |
||||
|
for (unsigned int i = 1; i <= nl3; i ++) { |
||||
|
for (unsigned int j = 1; j <= nc3; j ++) { |
||||
|
ret.setValueAt(nl1 + i, nc1 + j, Q3.getValueAt(i, j)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
unsigned int nl4 = Q4.getLineNb(); |
||||
|
unsigned int nc4 = Q4.getColNb(); |
||||
|
for (unsigned int i = 1; i <= nl4; i ++) { |
||||
|
for (unsigned int j = 1; j <= nc4; j ++) { |
||||
|
ret.setValueAt(nl1 + i, j, Q2.getValueAt(i, j)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
cout << "Résultat temporaire:" << endl << *this << endl <<ret << endl; |
||||
|
|
||||
|
return ret; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Matrix Matrix::invert() const { |
||||
|
// the Matrix must be a square Matrix
|
||||
|
if (this->getLineNb() != this->getColNb()) { |
||||
|
// Error, simply return the matrix
|
||||
|
return *this; |
||||
|
} |
||||
|
|
||||
|
// we provide a positive defined matrix;
|
||||
|
Matrix m(*this); |
||||
|
Matrix mt = m.transpose(); |
||||
|
Matrix r = mt * m; |
||||
|
|
||||
|
unsigned int size; |
||||
|
isPowerOfTwo(r.getColNb(), &size); |
||||
|
|
||||
|
Matrix * toBeInverted = &r; |
||||
|
if (size != toBeInverted->getColNb()) { |
||||
|
// we must resize the Matrix
|
||||
|
toBeInverted = new Matrix(size, size); |
||||
|
unsigned int rSize = r.getColNb(); |
||||
|
for (unsigned int i = 1; i <= size; i++) { |
||||
|
for (unsigned int j = 1; j <= size; j++) { |
||||
|
double value = 0; |
||||
|
|
||||
|
if (i <= rSize && j <= rSize) { |
||||
|
value = r.getValueAt(i, j); |
||||
|
} else if (i == j) { |
||||
|
value = 1; |
||||
|
} |
||||
|
toBeInverted->setValueAt(i, j, value); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
cout << "La matrice qui va être effectivement inversée:" << endl << *toBeInverted << endl; |
||||
|
|
||||
|
Matrix invert = toBeInverted->invertR(); |
||||
|
Matrix small(this->getLineNb(), this->getColNb()); |
||||
|
|
||||
|
// copy the inverted matrix into the source matrix
|
||||
|
int c = this->getColNb(); |
||||
|
int l = this->getLineNb(); |
||||
|
|
||||
|
for (int i = 1; i <= l; i++) { |
||||
|
for (int j = 1; j <= c; j++) { |
||||
|
small.setValueAt(i, j, invert.getValueAt(i, j)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (toBeInverted != &r) { |
||||
|
delete toBeInverted; |
||||
|
} |
||||
|
|
||||
|
return small * mt; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Matrix Matrix::getQuarter(int quarter) const { |
||||
|
unsigned int nbLine = this->getLineNb(); |
||||
|
unsigned int nbCol = this->getColNb(); |
||||
|
|
||||
|
Matrix m((nbLine / 2) + (nbLine % 2), (nbCol / 2) + (nbCol % 2)); |
||||
|
unsigned int lineStart, lineEnd, colStart, colEnd; |
||||
|
if (quarter == 1) { |
||||
|
// return up left quarter
|
||||
|
lineStart = 1; |
||||
|
colStart = 1; |
||||
|
lineEnd = nbLine / 2; |
||||
|
colEnd = nbCol / 2; |
||||
|
if ((nbLine % 2) != 0) { |
||||
|
// nbLine odd
|
||||
|
lineEnd++; |
||||
|
} |
||||
|
if ((nbCol % 2) != 0) { |
||||
|
// nbCol odd
|
||||
|
colEnd++; |
||||
|
} |
||||
|
} else if (quarter == 2) { |
||||
|
// return up right quarter
|
||||
|
lineStart = 1; |
||||
|
lineEnd = nbLine / 2; |
||||
|
colStart = nbCol / 2 + 1; |
||||
|
colEnd = nbCol; |
||||
|
if ((nbLine % 2) != 0) { |
||||
|
// nbLine odd
|
||||
|
lineEnd++; |
||||
|
} |
||||
|
} else if (quarter == 3) { |
||||
|
// return down right quarter
|
||||
|
lineStart = nbLine / 2 + 1; |
||||
|
lineEnd = nbLine; |
||||
|
colStart = nbCol / 2 + 1; |
||||
|
colEnd = nbCol; |
||||
|
} else if (quarter == 4) { |
||||
|
// return down left quarter
|
||||
|
lineStart = nbLine / 2 + 1; |
||||
|
lineEnd = nbLine; |
||||
|
colStart = 1; |
||||
|
colEnd = (nbCol /2) + (nbCol %2); |
||||
|
if ((nbCol % 2) != 0) { |
||||
|
// nbCol odd
|
||||
|
colEnd++; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
unsigned int im = 1, jm = 1; |
||||
|
for(unsigned int i = lineStart; i <= lineEnd; i++) { |
||||
|
for(unsigned int j = colStart; j <= colEnd; j++) { |
||||
|
m.setValueAt(im, jm, this->getValueAt(i,j)); |
||||
|
jm ++; |
||||
|
} |
||||
|
jm = 1; |
||||
|
im ++; |
||||
|
} |
||||
|
|
||||
|
return m; |
||||
|
} |
||||
|
|
||||
|
Matrix Matrix::operator*(const Matrix & m) const { |
||||
|
assert(this->getColNb() == m.getLineNb()); |
||||
|
|
||||
|
Matrix mat(this->getLineNb(), m.getColNb()); |
||||
|
|
||||
|
for (unsigned int r = 1; r <= mat.getLineNb(); r++) { |
||||
|
for (unsigned int c = 1; c <= mat.getColNb(); c++) { |
||||
|
double tmp = 0; |
||||
|
|
||||
|
for (unsigned int i = 1; i <= this->getColNb(); i++) { |
||||
|
//cout << r << " " << c << " " << i << endl;
|
||||
|
tmp += this->getValueAt(r, i) * m.getValueAt(i, c); |
||||
|
} |
||||
|
|
||||
|
mat.setValueAt(r, c, tmp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return mat; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
ostream & operator<<(ostream & os, const Matrix & m) { |
||||
|
unsigned int nbLine = m.getLineNb(); |
||||
|
unsigned int nbCol = m.getColNb(); |
||||
|
|
||||
|
// write values, line by line
|
||||
|
for (unsigned int i = 1; i <= nbLine; i++) { |
||||
|
if (i == 1) { |
||||
|
os << "["; |
||||
|
} else { |
||||
|
os << " "; |
||||
|
} |
||||
|
|
||||
|
for (unsigned int j = 1; j <= nbCol; j++) { |
||||
|
os << m.getValueAt(i, j) << " "; |
||||
|
} |
||||
|
|
||||
|
if (i == nbLine) { |
||||
|
os << "]"; |
||||
|
} |
||||
|
|
||||
|
os << endl; |
||||
|
} |
||||
|
|
||||
|
return os; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
istream & operator>>(istream & is, Matrix ** m) { |
||||
|
// write number of line and column
|
||||
|
unsigned int nbLine; |
||||
|
unsigned int nbCol; |
||||
|
|
||||
|
is >> nbLine; |
||||
|
is >> nbCol; |
||||
|
|
||||
|
*m = new Matrix(nbLine, nbCol); |
||||
|
|
||||
|
// write values, line by line
|
||||
|
for (unsigned int i = 1; i <= nbLine; i++) { |
||||
|
for (unsigned int j = 1; j <= nbCol; j++) { |
||||
|
double val; |
||||
|
|
||||
|
is >> val; |
||||
|
(*m)->setValueAt(i, j, val); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return is; |
||||
|
} |
||||
|
|
||||
|
bool isPowerOfTwo(unsigned int n, unsigned int * max) { |
||||
|
unsigned int shifted = 0x80000000; |
||||
|
bool power = true; |
||||
|
int nb = sizeof(shifted) * 8; |
||||
|
|
||||
|
// Find a bit
|
||||
|
while ((shifted & n) == 0 && nb != 0) { |
||||
|
shifted >>= 1; |
||||
|
nb--; |
||||
|
} |
||||
|
|
||||
|
// Is it the only one ?
|
||||
|
if ((shifted & n) != n) { |
||||
|
power = false; |
||||
|
if (max != 0) { |
||||
|
*max = shifted << 1; |
||||
|
} |
||||
|
} else if (max != 0) { |
||||
|
*max = n; |
||||
|
} |
||||
|
|
||||
|
return power; |
||||
|
} |
||||
@ -0,0 +1,285 @@ |
|||||
|
/**
|
||||
|
* #(@)Matrix.h ENSICAEN 2005-10-12 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe4-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe4-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Objectifs du TP: allocation dynamique, copie et destruction des objets, |
||||
|
* surcharge d'operateurs, programmation d'une classe concrète, CHoix entre |
||||
|
* fonctions membres, non-membres, |
||||
|
*/ |
||||
|
|
||||
|
/*
|
||||
|
* @version 0.0.1 |
||||
|
* |
||||
|
* @done: nothing |
||||
|
* |
||||
|
* @todo: all |
||||
|
*/ |
||||
|
|
||||
|
#ifndef __MATRIX_H__ |
||||
|
#define __MATRIX_H__ |
||||
|
|
||||
|
#include <cassert> |
||||
|
#include <iostream> |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
/**
|
||||
|
* A class wich implements the mathematical concept of Matrix |
||||
|
*/ |
||||
|
class Matrix { |
||||
|
|
||||
|
public: |
||||
|
|
||||
|
/**
|
||||
|
* Default constructor. The caller has to provide the |
||||
|
* size of the future matrix. |
||||
|
* |
||||
|
* @param line_nb number of line, default 2 |
||||
|
* @param col_nb number of column, default 2 |
||||
|
*/ |
||||
|
Matrix(unsigned int line_nb = 2, unsigned int col_nb = 2); |
||||
|
|
||||
|
/**
|
||||
|
* Clone constructor |
||||
|
* |
||||
|
* @param m original matrix |
||||
|
*/ |
||||
|
Matrix(const Matrix & m); |
||||
|
|
||||
|
/**
|
||||
|
* Matrix destructor. Free memory that is used to store |
||||
|
* the coeficient. |
||||
|
*/ |
||||
|
~Matrix(); |
||||
|
|
||||
|
/**
|
||||
|
* Assignment operator. |
||||
|
* |
||||
|
* @param m original matrix |
||||
|
* @retun a reference on the matrix' copy |
||||
|
*/ |
||||
|
Matrix & operator=(const Matrix & m); |
||||
|
|
||||
|
/**
|
||||
|
* Equality check operator. |
||||
|
* |
||||
|
* @param m second matrix |
||||
|
* @retun true if the matrices are identical, else false |
||||
|
*/ |
||||
|
bool operator==(const Matrix & m) const; |
||||
|
|
||||
|
/**
|
||||
|
* Inequality check operator. |
||||
|
* |
||||
|
* @param m second matrix |
||||
|
* @retun true if the matrices are different, else true |
||||
|
*/ |
||||
|
bool operator!=(const Matrix & m) const; |
||||
|
|
||||
|
/**
|
||||
|
* Addition operator. |
||||
|
* |
||||
|
* @param m second matrix |
||||
|
* @return the addition of the two matrix |
||||
|
*/ |
||||
|
Matrix operator+(const Matrix & m) const; |
||||
|
|
||||
|
/**
|
||||
|
* Addition and affectation operator. |
||||
|
* |
||||
|
* @param m second matrix |
||||
|
* @return a reference to this |
||||
|
*/ |
||||
|
Matrix & operator+=(const Matrix & m); |
||||
|
|
||||
|
/**
|
||||
|
* Minus operator. |
||||
|
* |
||||
|
* @param m second matrix |
||||
|
* @return the difference between the two matrix |
||||
|
*/ |
||||
|
Matrix operator-(const Matrix & m) const; |
||||
|
|
||||
|
/**
|
||||
|
* Minus and affectation operator. |
||||
|
* |
||||
|
* @param m second matrix |
||||
|
* @return a reference to this |
||||
|
*/ |
||||
|
Matrix & operator-=(const Matrix & m); |
||||
|
|
||||
|
/**
|
||||
|
* Unary minus operator. |
||||
|
* |
||||
|
* @return a new matrix |
||||
|
*/ |
||||
|
Matrix operator-() const; |
||||
|
|
||||
|
/**
|
||||
|
* Transposes this matrix. |
||||
|
* |
||||
|
* @return a new transposed matrix. |
||||
|
*/ |
||||
|
Matrix transpose() const; |
||||
|
|
||||
|
/**
|
||||
|
* Invert the Matrix. This is the entry point for the recursive |
||||
|
* inversion process. It init the matrix so it will be inversible |
||||
|
* |
||||
|
* @return a new matrix, inverted |
||||
|
*/ |
||||
|
Matrix invert() const; |
||||
|
|
||||
|
/**
|
||||
|
* Multiply operator. |
||||
|
* |
||||
|
* @param m the second matrix. |
||||
|
* @return the result. |
||||
|
*/ |
||||
|
Matrix operator*(const Matrix & m) const; |
||||
|
|
||||
|
/**
|
||||
|
* Return a pointer linked to the previous element of the first element |
||||
|
* of the row, so that the notation m[row][col] works (with row in [1,n] |
||||
|
* and col in [1,n]. |
||||
|
* |
||||
|
* @param row the row number (between 1 and _line_nb). |
||||
|
* @return a pointer to the row. |
||||
|
*/ |
||||
|
inline double * operator[](unsigned int row) { |
||||
|
assert(row > 0 && row <= this->getLineNb()); |
||||
|
|
||||
|
return _lines[row - 1] - 1; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Number of lines getter |
||||
|
* |
||||
|
* @return the number of lines |
||||
|
*/ |
||||
|
inline unsigned int getLineNb() const { |
||||
|
return _line_nb; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Number of columns getter |
||||
|
* |
||||
|
* @return the number of comumns |
||||
|
*/ |
||||
|
inline unsigned int getColNb() const { |
||||
|
return _col_nb; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Matrix values getter. |
||||
|
* |
||||
|
* @param r the row number [1,n] |
||||
|
* @param c the col number [1,n] |
||||
|
* @return the value. |
||||
|
*/ |
||||
|
inline double getValueAt(unsigned int r, unsigned int c) const { |
||||
|
assert(r > 0 && r <= _line_nb); |
||||
|
assert(c > 0 && c <= _col_nb); |
||||
|
return _lines[r - 1][c - 1]; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Matrix values setter. |
||||
|
* |
||||
|
* @param r the row number [1,n] |
||||
|
* @param c the col number [1,n] |
||||
|
* @param v the value. |
||||
|
*/ |
||||
|
inline void setValueAt(unsigned int r, unsigned int c, double v) { |
||||
|
assert(r > 0 && r <= _line_nb); |
||||
|
assert(c > 0 && c <= _col_nb); |
||||
|
_lines[r - 1][c - 1] = v; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Create a Matrix which is a copy of a quarter of the current Matrix |
||||
|
* The returned quarter is: |
||||
|
* |
||||
|
* 1 => up left |
||||
|
* 2 => up right |
||||
|
* 3 => down right |
||||
|
* 4 => down left |
||||
|
* |
||||
|
* @param quarter the quarter to return |
||||
|
* @return a new Matrix |
||||
|
*/ |
||||
|
Matrix getQuarter(int quarter) const; |
||||
|
|
||||
|
|
||||
|
private: |
||||
|
/**
|
||||
|
* Inverts this matrix (recursive) |
||||
|
* |
||||
|
* @return a new inverted matrix. |
||||
|
*/ |
||||
|
Matrix invertR() const; |
||||
|
|
||||
|
/**
|
||||
|
* The number of line of the matrix |
||||
|
*/ |
||||
|
unsigned int _line_nb; |
||||
|
|
||||
|
/**
|
||||
|
* The number of line of the matrix |
||||
|
*/ |
||||
|
unsigned int _col_nb; |
||||
|
|
||||
|
/**
|
||||
|
* An array of pointers, each allowing access to a column |
||||
|
*/ |
||||
|
double ** _lines; |
||||
|
|
||||
|
/**
|
||||
|
* Memory area in wich columns are stored |
||||
|
*/ |
||||
|
double * _columns; |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
/**
|
||||
|
* Write a Matrix to output stream. Following format is used: |
||||
|
* line_number column number values (line by line) |
||||
|
* |
||||
|
* @param os the output stream |
||||
|
* @param m the matrix to write out |
||||
|
* @return the output stream |
||||
|
*/ |
||||
|
ostream & operator<<(ostream & os, const Matrix & m); |
||||
|
|
||||
|
/**
|
||||
|
* Get a Matrix from input stream. Following format is used: |
||||
|
* line_number column number values (line by line) |
||||
|
* |
||||
|
* @param is the input stream |
||||
|
* @param m a pointer on a Matrix pointer. the param is used |
||||
|
* to write out the pointer to the new Matrix |
||||
|
* @return the input stream |
||||
|
*/ |
||||
|
istream & operator>>(istream & is, Matrix ** m); |
||||
|
|
||||
|
/**
|
||||
|
* Tests if n is a power of two. |
||||
|
* |
||||
|
* @param n the number to test. |
||||
|
* @param max a pointer to store the power of two upper or equal to n |
||||
|
* @return true or false. |
||||
|
*/ |
||||
|
bool isPowerOfTwo(unsigned int n, unsigned int * max); |
||||
|
|
||||
|
#endif /* define __MATRIX_H__ */ |
||||
@ -0,0 +1,23 @@ |
|||||
|
Utilisation des Fonctions membres en tant qu'amies |
||||
|
|
||||
|
Les fonctions membres d'une classe sont implicitement "amies de la classe", ce |
||||
|
qui implique qu'une fonction membre peut accéder aux variables d'instance de |
||||
|
l'objet sur lequel elle est appelée, mais aussi le cas échéant, aux variables |
||||
|
d'instance d'un objet de meme classe passé en parametre. Cette propriété est |
||||
|
beaucoup utilisée dans notre implémentation de ce TP, notamment pour nous |
||||
|
éviter l'écriture de nombreux accesseurs privés. |
||||
|
|
||||
|
Cependant cette propriété met à mal le concept d'encapsulation, car il permet |
||||
|
à des objets d'accéder aux champs privés d'autres objets. Pour relativiser, |
||||
|
nous argumenterons que le code violant l'encapsulation est interne à la classe |
||||
|
"violée" et donc qu'il est écrit en tenant compte de l'implémentation de |
||||
|
celle ci, pour en tirer le meilleur partis en terme d'efficacité. Ce souci |
||||
|
d'efficacité est un élément important lors des choix d'implémentation, car |
||||
|
l'utilisation, somme toute périlleuse et difficile du langage C++, n'est due |
||||
|
qu'a la propriété de ce langage de permettre l'écriture d'applications très |
||||
|
efficaces, avantage qu'il serait peu judicieux de perdre en s'encombrant de |
||||
|
lourdeurs. Par ailleurs, l'avantage qu'a le respect de l'encapsulation à |
||||
|
l'intérieur d'un classe est de pouvoir changer la représentation de données |
||||
|
en ayant à réécrir qu'un minimum d'acceseurs. Or dans notre cas (TP3), |
||||
|
le format des données en interne est fixé une fois pour toute, ce qui |
||||
|
réduit considérablement l'interet induit par le respect de l'encapsulation. |
||||
@ -0,0 +1,2 @@ |
|||||
|
Nicolas MASSE <nicolas27.masse@laposte.net> |
||||
|
Thomas LIMIN <thomas.limin@laposte.net> |
||||
@ -0,0 +1,340 @@ |
|||||
|
GNU GENERAL PUBLIC LICENSE |
||||
|
Version 2, June 1991 |
||||
|
|
||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc. |
||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
Everyone is permitted to copy and distribute verbatim copies |
||||
|
of this license document, but changing it is not allowed. |
||||
|
|
||||
|
Preamble |
||||
|
|
||||
|
The licenses for most software are designed to take away your |
||||
|
freedom to share and change it. By contrast, the GNU General Public |
||||
|
License is intended to guarantee your freedom to share and change free |
||||
|
software--to make sure the software is free for all its users. This |
||||
|
General Public License applies to most of the Free Software |
||||
|
Foundation's software and to any other program whose authors commit to |
||||
|
using it. (Some other Free Software Foundation software is covered by |
||||
|
the GNU Library General Public License instead.) You can apply it to |
||||
|
your programs, too. |
||||
|
|
||||
|
When we speak of free software, we are referring to freedom, not |
||||
|
price. Our General Public Licenses are designed to make sure that you |
||||
|
have the freedom to distribute copies of free software (and charge for |
||||
|
this service if you wish), that you receive source code or can get it |
||||
|
if you want it, that you can change the software or use pieces of it |
||||
|
in new free programs; and that you know you can do these things. |
||||
|
|
||||
|
To protect your rights, we need to make restrictions that forbid |
||||
|
anyone to deny you these rights or to ask you to surrender the rights. |
||||
|
These restrictions translate to certain responsibilities for you if you |
||||
|
distribute copies of the software, or if you modify it. |
||||
|
|
||||
|
For example, if you distribute copies of such a program, whether |
||||
|
gratis or for a fee, you must give the recipients all the rights that |
||||
|
you have. You must make sure that they, too, receive or can get the |
||||
|
source code. And you must show them these terms so they know their |
||||
|
rights. |
||||
|
|
||||
|
We protect your rights with two steps: (1) copyright the software, and |
||||
|
(2) offer you this license which gives you legal permission to copy, |
||||
|
distribute and/or modify the software. |
||||
|
|
||||
|
Also, for each author's protection and ours, we want to make certain |
||||
|
that everyone understands that there is no warranty for this free |
||||
|
software. If the software is modified by someone else and passed on, we |
||||
|
want its recipients to know that what they have is not the original, so |
||||
|
that any problems introduced by others will not reflect on the original |
||||
|
authors' reputations. |
||||
|
|
||||
|
Finally, any free program is threatened constantly by software |
||||
|
patents. We wish to avoid the danger that redistributors of a free |
||||
|
program will individually obtain patent licenses, in effect making the |
||||
|
program proprietary. To prevent this, we have made it clear that any |
||||
|
patent must be licensed for everyone's free use or not licensed at all. |
||||
|
|
||||
|
The precise terms and conditions for copying, distribution and |
||||
|
modification follow. |
||||
|
|
||||
|
GNU GENERAL PUBLIC LICENSE |
||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
||||
|
|
||||
|
0. This License applies to any program or other work which contains |
||||
|
a notice placed by the copyright holder saying it may be distributed |
||||
|
under the terms of this General Public License. The "Program", below, |
||||
|
refers to any such program or work, and a "work based on the Program" |
||||
|
means either the Program or any derivative work under copyright law: |
||||
|
that is to say, a work containing the Program or a portion of it, |
||||
|
either verbatim or with modifications and/or translated into another |
||||
|
language. (Hereinafter, translation is included without limitation in |
||||
|
the term "modification".) Each licensee is addressed as "you". |
||||
|
|
||||
|
Activities other than copying, distribution and modification are not |
||||
|
covered by this License; they are outside its scope. The act of |
||||
|
running the Program is not restricted, and the output from the Program |
||||
|
is covered only if its contents constitute a work based on the |
||||
|
Program (independent of having been made by running the Program). |
||||
|
Whether that is true depends on what the Program does. |
||||
|
|
||||
|
1. You may copy and distribute verbatim copies of the Program's |
||||
|
source code as you receive it, in any medium, provided that you |
||||
|
conspicuously and appropriately publish on each copy an appropriate |
||||
|
copyright notice and disclaimer of warranty; keep intact all the |
||||
|
notices that refer to this License and to the absence of any warranty; |
||||
|
and give any other recipients of the Program a copy of this License |
||||
|
along with the Program. |
||||
|
|
||||
|
You may charge a fee for the physical act of transferring a copy, and |
||||
|
you may at your option offer warranty protection in exchange for a fee. |
||||
|
|
||||
|
2. You may modify your copy or copies of the Program or any portion |
||||
|
of it, thus forming a work based on the Program, and copy and |
||||
|
distribute such modifications or work under the terms of Section 1 |
||||
|
above, provided that you also meet all of these conditions: |
||||
|
|
||||
|
a) You must cause the modified files to carry prominent notices |
||||
|
stating that you changed the files and the date of any change. |
||||
|
|
||||
|
b) You must cause any work that you distribute or publish, that in |
||||
|
whole or in part contains or is derived from the Program or any |
||||
|
part thereof, to be licensed as a whole at no charge to all third |
||||
|
parties under the terms of this License. |
||||
|
|
||||
|
c) If the modified program normally reads commands interactively |
||||
|
when run, you must cause it, when started running for such |
||||
|
interactive use in the most ordinary way, to print or display an |
||||
|
announcement including an appropriate copyright notice and a |
||||
|
notice that there is no warranty (or else, saying that you provide |
||||
|
a warranty) and that users may redistribute the program under |
||||
|
these conditions, and telling the user how to view a copy of this |
||||
|
License. (Exception: if the Program itself is interactive but |
||||
|
does not normally print such an announcement, your work based on |
||||
|
the Program is not required to print an announcement.) |
||||
|
|
||||
|
These requirements apply to the modified work as a whole. If |
||||
|
identifiable sections of that work are not derived from the Program, |
||||
|
and can be reasonably considered independent and separate works in |
||||
|
themselves, then this License, and its terms, do not apply to those |
||||
|
sections when you distribute them as separate works. But when you |
||||
|
distribute the same sections as part of a whole which is a work based |
||||
|
on the Program, the distribution of the whole must be on the terms of |
||||
|
this License, whose permissions for other licensees extend to the |
||||
|
entire whole, and thus to each and every part regardless of who wrote it. |
||||
|
|
||||
|
Thus, it is not the intent of this section to claim rights or contest |
||||
|
your rights to work written entirely by you; rather, the intent is to |
||||
|
exercise the right to control the distribution of derivative or |
||||
|
collective works based on the Program. |
||||
|
|
||||
|
In addition, mere aggregation of another work not based on the Program |
||||
|
with the Program (or with a work based on the Program) on a volume of |
||||
|
a storage or distribution medium does not bring the other work under |
||||
|
the scope of this License. |
||||
|
|
||||
|
3. You may copy and distribute the Program (or a work based on it, |
||||
|
under Section 2) in object code or executable form under the terms of |
||||
|
Sections 1 and 2 above provided that you also do one of the following: |
||||
|
|
||||
|
a) Accompany it with the complete corresponding machine-readable |
||||
|
source code, which must be distributed under the terms of Sections |
||||
|
1 and 2 above on a medium customarily used for software interchange; or, |
||||
|
|
||||
|
b) Accompany it with a written offer, valid for at least three |
||||
|
years, to give any third party, for a charge no more than your |
||||
|
cost of physically performing source distribution, a complete |
||||
|
machine-readable copy of the corresponding source code, to be |
||||
|
distributed under the terms of Sections 1 and 2 above on a medium |
||||
|
customarily used for software interchange; or, |
||||
|
|
||||
|
c) Accompany it with the information you received as to the offer |
||||
|
to distribute corresponding source code. (This alternative is |
||||
|
allowed only for noncommercial distribution and only if you |
||||
|
received the program in object code or executable form with such |
||||
|
an offer, in accord with Subsection b above.) |
||||
|
|
||||
|
The source code for a work means the preferred form of the work for |
||||
|
making modifications to it. For an executable work, complete source |
||||
|
code means all the source code for all modules it contains, plus any |
||||
|
associated interface definition files, plus the scripts used to |
||||
|
control compilation and installation of the executable. However, as a |
||||
|
special exception, the source code distributed need not include |
||||
|
anything that is normally distributed (in either source or binary |
||||
|
form) with the major components (compiler, kernel, and so on) of the |
||||
|
operating system on which the executable runs, unless that component |
||||
|
itself accompanies the executable. |
||||
|
|
||||
|
If distribution of executable or object code is made by offering |
||||
|
access to copy from a designated place, then offering equivalent |
||||
|
access to copy the source code from the same place counts as |
||||
|
distribution of the source code, even though third parties are not |
||||
|
compelled to copy the source along with the object code. |
||||
|
|
||||
|
4. You may not copy, modify, sublicense, or distribute the Program |
||||
|
except as expressly provided under this License. Any attempt |
||||
|
otherwise to copy, modify, sublicense or distribute the Program is |
||||
|
void, and will automatically terminate your rights under this License. |
||||
|
However, parties who have received copies, or rights, from you under |
||||
|
this License will not have their licenses terminated so long as such |
||||
|
parties remain in full compliance. |
||||
|
|
||||
|
5. You are not required to accept this License, since you have not |
||||
|
signed it. However, nothing else grants you permission to modify or |
||||
|
distribute the Program or its derivative works. These actions are |
||||
|
prohibited by law if you do not accept this License. Therefore, by |
||||
|
modifying or distributing the Program (or any work based on the |
||||
|
Program), you indicate your acceptance of this License to do so, and |
||||
|
all its terms and conditions for copying, distributing or modifying |
||||
|
the Program or works based on it. |
||||
|
|
||||
|
6. Each time you redistribute the Program (or any work based on the |
||||
|
Program), the recipient automatically receives a license from the |
||||
|
original licensor to copy, distribute or modify the Program subject to |
||||
|
these terms and conditions. You may not impose any further |
||||
|
restrictions on the recipients' exercise of the rights granted herein. |
||||
|
You are not responsible for enforcing compliance by third parties to |
||||
|
this License. |
||||
|
|
||||
|
7. If, as a consequence of a court judgment or allegation of patent |
||||
|
infringement or for any other reason (not limited to patent issues), |
||||
|
conditions are imposed on you (whether by court order, agreement or |
||||
|
otherwise) that contradict the conditions of this License, they do not |
||||
|
excuse you from the conditions of this License. If you cannot |
||||
|
distribute so as to satisfy simultaneously your obligations under this |
||||
|
License and any other pertinent obligations, then as a consequence you |
||||
|
may not distribute the Program at all. For example, if a patent |
||||
|
license would not permit royalty-free redistribution of the Program by |
||||
|
all those who receive copies directly or indirectly through you, then |
||||
|
the only way you could satisfy both it and this License would be to |
||||
|
refrain entirely from distribution of the Program. |
||||
|
|
||||
|
If any portion of this section is held invalid or unenforceable under |
||||
|
any particular circumstance, the balance of the section is intended to |
||||
|
apply and the section as a whole is intended to apply in other |
||||
|
circumstances. |
||||
|
|
||||
|
It is not the purpose of this section to induce you to infringe any |
||||
|
patents or other property right claims or to contest validity of any |
||||
|
such claims; this section has the sole purpose of protecting the |
||||
|
integrity of the free software distribution system, which is |
||||
|
implemented by public license practices. Many people have made |
||||
|
generous contributions to the wide range of software distributed |
||||
|
through that system in reliance on consistent application of that |
||||
|
system; it is up to the author/donor to decide if he or she is willing |
||||
|
to distribute software through any other system and a licensee cannot |
||||
|
impose that choice. |
||||
|
|
||||
|
This section is intended to make thoroughly clear what is believed to |
||||
|
be a consequence of the rest of this License. |
||||
|
|
||||
|
8. If the distribution and/or use of the Program is restricted in |
||||
|
certain countries either by patents or by copyrighted interfaces, the |
||||
|
original copyright holder who places the Program under this License |
||||
|
may add an explicit geographical distribution limitation excluding |
||||
|
those countries, so that distribution is permitted only in or among |
||||
|
countries not thus excluded. In such case, this License incorporates |
||||
|
the limitation as if written in the body of this License. |
||||
|
|
||||
|
9. The Free Software Foundation may publish revised and/or new versions |
||||
|
of the General Public License from time to time. Such new versions will |
||||
|
be similar in spirit to the present version, but may differ in detail to |
||||
|
address new problems or concerns. |
||||
|
|
||||
|
Each version is given a distinguishing version number. If the Program |
||||
|
specifies a version number of this License which applies to it and "any |
||||
|
later version", you have the option of following the terms and conditions |
||||
|
either of that version or of any later version published by the Free |
||||
|
Software Foundation. If the Program does not specify a version number of |
||||
|
this License, you may choose any version ever published by the Free Software |
||||
|
Foundation. |
||||
|
|
||||
|
10. If you wish to incorporate parts of the Program into other free |
||||
|
programs whose distribution conditions are different, write to the author |
||||
|
to ask for permission. For software which is copyrighted by the Free |
||||
|
Software Foundation, write to the Free Software Foundation; we sometimes |
||||
|
make exceptions for this. Our decision will be guided by the two goals |
||||
|
of preserving the free status of all derivatives of our free software and |
||||
|
of promoting the sharing and reuse of software generally. |
||||
|
|
||||
|
NO WARRANTY |
||||
|
|
||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED |
||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS |
||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE |
||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, |
||||
|
REPAIR OR CORRECTION. |
||||
|
|
||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, |
||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING |
||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED |
||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY |
||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER |
||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE |
||||
|
POSSIBILITY OF SUCH DAMAGES. |
||||
|
|
||||
|
END OF TERMS AND CONDITIONS |
||||
|
|
||||
|
How to Apply These Terms to Your New Programs |
||||
|
|
||||
|
If you develop a new program, and you want it to be of the greatest |
||||
|
possible use to the public, the best way to achieve this is to make it |
||||
|
free software which everyone can redistribute and change under these terms. |
||||
|
|
||||
|
To do so, attach the following notices to the program. It is safest |
||||
|
to attach them to the start of each source file to most effectively |
||||
|
convey the exclusion of warranty; and each file should have at least |
||||
|
the "copyright" line and a pointer to where the full notice is found. |
||||
|
|
||||
|
<one line to give the program's name and a brief idea of what it does.> |
||||
|
Copyright (C) <year> <name of author> |
||||
|
|
||||
|
This program is free software; you can redistribute it and/or modify |
||||
|
it under the terms of the GNU General Public License as published by |
||||
|
the Free Software Foundation; either version 2 of the License, or |
||||
|
(at your option) any later version. |
||||
|
|
||||
|
This program is distributed in the hope that it will be useful, |
||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
GNU General Public License for more details. |
||||
|
|
||||
|
You should have received a copy of the GNU General Public License |
||||
|
along with this program; if not, write to the Free Software |
||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
|
|
||||
|
|
||||
|
Also add information on how to contact you by electronic and paper mail. |
||||
|
|
||||
|
If the program is interactive, make it output a short notice like this |
||||
|
when it starts in an interactive mode: |
||||
|
|
||||
|
Gnomovision version 69, Copyright (C) year name of author |
||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
||||
|
This is free software, and you are welcome to redistribute it |
||||
|
under certain conditions; type `show c' for details. |
||||
|
|
||||
|
The hypothetical commands `show w' and `show c' should show the appropriate |
||||
|
parts of the General Public License. Of course, the commands you use may |
||||
|
be called something other than `show w' and `show c'; they could even be |
||||
|
mouse-clicks or menu items--whatever suits your program. |
||||
|
|
||||
|
You should also get your employer (if you work as a programmer) or your |
||||
|
school, if any, to sign a "copyright disclaimer" for the program, if |
||||
|
necessary. Here is a sample; alter the names: |
||||
|
|
||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program |
||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker. |
||||
|
|
||||
|
<signature of Ty Coon>, 1 April 1989 |
||||
|
Ty Coon, President of Vice |
||||
|
|
||||
|
This General Public License does not permit incorporating your program into |
||||
|
proprietary programs. If your program is a subroutine library, you may |
||||
|
consider it more useful to permit linking proprietary applications with the |
||||
|
library. If this is what you want to do, use the GNU Library General |
||||
|
Public License instead of this License. |
||||
@ -0,0 +1,275 @@ |
|||||
|
# Doxyfile 1.4.1-KDevelop |
||||
|
|
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Project related configuration options |
||||
|
#--------------------------------------------------------------------------- |
||||
|
PROJECT_NAME = tp4_comptesbancaires.kdevelop |
||||
|
PROJECT_NUMBER = 0.1 |
||||
|
OUTPUT_DIRECTORY = |
||||
|
CREATE_SUBDIRS = NO |
||||
|
OUTPUT_LANGUAGE = English |
||||
|
USE_WINDOWS_ENCODING = NO |
||||
|
BRIEF_MEMBER_DESC = YES |
||||
|
REPEAT_BRIEF = YES |
||||
|
ABBREVIATE_BRIEF = "The $name class" \ |
||||
|
"The $name widget" \ |
||||
|
"The $name file" \ |
||||
|
is \ |
||||
|
provides \ |
||||
|
specifies \ |
||||
|
contains \ |
||||
|
represents \ |
||||
|
a \ |
||||
|
an \ |
||||
|
the |
||||
|
ALWAYS_DETAILED_SEC = NO |
||||
|
INLINE_INHERITED_MEMB = NO |
||||
|
FULL_PATH_NAMES = YES |
||||
|
STRIP_FROM_PATH = /home/nicolas/repository/ENSI_2ndY/Cpp/TP3_12-10-2005_CalculMatriciel/ |
||||
|
STRIP_FROM_INC_PATH = |
||||
|
SHORT_NAMES = NO |
||||
|
JAVADOC_AUTOBRIEF = NO |
||||
|
MULTILINE_CPP_IS_BRIEF = NO |
||||
|
DETAILS_AT_TOP = NO |
||||
|
INHERIT_DOCS = YES |
||||
|
DISTRIBUTE_GROUP_DOC = NO |
||||
|
TAB_SIZE = 8 |
||||
|
ALIASES = |
||||
|
OPTIMIZE_OUTPUT_FOR_C = NO |
||||
|
OPTIMIZE_OUTPUT_JAVA = NO |
||||
|
SUBGROUPING = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Build related configuration options |
||||
|
#--------------------------------------------------------------------------- |
||||
|
EXTRACT_ALL = NO |
||||
|
EXTRACT_PRIVATE = NO |
||||
|
EXTRACT_STATIC = NO |
||||
|
EXTRACT_LOCAL_CLASSES = YES |
||||
|
EXTRACT_LOCAL_METHODS = NO |
||||
|
HIDE_UNDOC_MEMBERS = NO |
||||
|
HIDE_UNDOC_CLASSES = NO |
||||
|
HIDE_FRIEND_COMPOUNDS = NO |
||||
|
HIDE_IN_BODY_DOCS = NO |
||||
|
INTERNAL_DOCS = NO |
||||
|
CASE_SENSE_NAMES = YES |
||||
|
HIDE_SCOPE_NAMES = NO |
||||
|
SHOW_INCLUDE_FILES = YES |
||||
|
INLINE_INFO = YES |
||||
|
SORT_MEMBER_DOCS = YES |
||||
|
SORT_BRIEF_DOCS = NO |
||||
|
SORT_BY_SCOPE_NAME = NO |
||||
|
GENERATE_TODOLIST = YES |
||||
|
GENERATE_TESTLIST = YES |
||||
|
GENERATE_BUGLIST = YES |
||||
|
GENERATE_DEPRECATEDLIST= YES |
||||
|
ENABLED_SECTIONS = |
||||
|
MAX_INITIALIZER_LINES = 30 |
||||
|
SHOW_USED_FILES = YES |
||||
|
SHOW_DIRECTORIES = YES |
||||
|
FILE_VERSION_FILTER = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to warning and progress messages |
||||
|
#--------------------------------------------------------------------------- |
||||
|
QUIET = NO |
||||
|
WARNINGS = YES |
||||
|
WARN_IF_UNDOCUMENTED = YES |
||||
|
WARN_IF_DOC_ERROR = YES |
||||
|
WARN_NO_PARAMDOC = NO |
||||
|
WARN_FORMAT = "$file:$line: $text" |
||||
|
WARN_LOGFILE = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the input files |
||||
|
#--------------------------------------------------------------------------- |
||||
|
INPUT = /home/nicolas/repository/ENSI_2ndY/Cpp/tp4_comptesbancaires |
||||
|
FILE_PATTERNS = *.c \ |
||||
|
*.cc \ |
||||
|
*.cxx \ |
||||
|
*.cpp \ |
||||
|
*.c++ \ |
||||
|
*.java \ |
||||
|
*.ii \ |
||||
|
*.ixx \ |
||||
|
*.ipp \ |
||||
|
*.i++ \ |
||||
|
*.inl \ |
||||
|
*.h \ |
||||
|
*.hh \ |
||||
|
*.hxx \ |
||||
|
*.hpp \ |
||||
|
*.h++ \ |
||||
|
*.idl \ |
||||
|
*.odl \ |
||||
|
*.cs \ |
||||
|
*.php \ |
||||
|
*.php3 \ |
||||
|
*.inc \ |
||||
|
*.m \ |
||||
|
*.mm \ |
||||
|
*.dox \ |
||||
|
*.C \ |
||||
|
*.CC \ |
||||
|
*.C++ \ |
||||
|
*.II \ |
||||
|
*.I++ \ |
||||
|
*.H \ |
||||
|
*.HH \ |
||||
|
*.H++ \ |
||||
|
*.CS \ |
||||
|
*.PHP \ |
||||
|
*.PHP3 \ |
||||
|
*.M \ |
||||
|
*.MM \ |
||||
|
*.C \ |
||||
|
*.H \ |
||||
|
*.tlh \ |
||||
|
*.diff \ |
||||
|
*.patch \ |
||||
|
*.moc \ |
||||
|
*.xpm \ |
||||
|
*.dox |
||||
|
RECURSIVE = yes |
||||
|
EXCLUDE = |
||||
|
EXCLUDE_SYMLINKS = NO |
||||
|
EXCLUDE_PATTERNS = |
||||
|
EXAMPLE_PATH = |
||||
|
EXAMPLE_PATTERNS = * |
||||
|
EXAMPLE_RECURSIVE = NO |
||||
|
IMAGE_PATH = |
||||
|
INPUT_FILTER = |
||||
|
FILTER_PATTERNS = |
||||
|
FILTER_SOURCE_FILES = NO |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to source browsing |
||||
|
#--------------------------------------------------------------------------- |
||||
|
SOURCE_BROWSER = NO |
||||
|
INLINE_SOURCES = NO |
||||
|
STRIP_CODE_COMMENTS = YES |
||||
|
REFERENCED_BY_RELATION = YES |
||||
|
REFERENCES_RELATION = YES |
||||
|
VERBATIM_HEADERS = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the alphabetical class index |
||||
|
#--------------------------------------------------------------------------- |
||||
|
ALPHABETICAL_INDEX = NO |
||||
|
COLS_IN_ALPHA_INDEX = 5 |
||||
|
IGNORE_PREFIX = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the HTML output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_HTML = YES |
||||
|
HTML_OUTPUT = html |
||||
|
HTML_FILE_EXTENSION = .html |
||||
|
HTML_HEADER = |
||||
|
HTML_FOOTER = |
||||
|
HTML_STYLESHEET = |
||||
|
HTML_ALIGN_MEMBERS = YES |
||||
|
GENERATE_HTMLHELP = NO |
||||
|
CHM_FILE = |
||||
|
HHC_LOCATION = |
||||
|
GENERATE_CHI = NO |
||||
|
BINARY_TOC = NO |
||||
|
TOC_EXPAND = NO |
||||
|
DISABLE_INDEX = NO |
||||
|
ENUM_VALUES_PER_LINE = 4 |
||||
|
GENERATE_TREEVIEW = NO |
||||
|
TREEVIEW_WIDTH = 250 |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the LaTeX output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_LATEX = YES |
||||
|
LATEX_OUTPUT = latex |
||||
|
LATEX_CMD_NAME = latex |
||||
|
MAKEINDEX_CMD_NAME = makeindex |
||||
|
COMPACT_LATEX = NO |
||||
|
PAPER_TYPE = a4wide |
||||
|
EXTRA_PACKAGES = |
||||
|
LATEX_HEADER = |
||||
|
PDF_HYPERLINKS = NO |
||||
|
USE_PDFLATEX = NO |
||||
|
LATEX_BATCHMODE = NO |
||||
|
LATEX_HIDE_INDICES = NO |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the RTF output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_RTF = NO |
||||
|
RTF_OUTPUT = rtf |
||||
|
COMPACT_RTF = NO |
||||
|
RTF_HYPERLINKS = NO |
||||
|
RTF_STYLESHEET_FILE = |
||||
|
RTF_EXTENSIONS_FILE = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the man page output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_MAN = NO |
||||
|
MAN_OUTPUT = man |
||||
|
MAN_EXTENSION = .3 |
||||
|
MAN_LINKS = NO |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the XML output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_XML = yes |
||||
|
XML_OUTPUT = xml |
||||
|
XML_SCHEMA = |
||||
|
XML_DTD = |
||||
|
XML_PROGRAMLISTING = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options for the AutoGen Definitions output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_AUTOGEN_DEF = NO |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# configuration options related to the Perl module output |
||||
|
#--------------------------------------------------------------------------- |
||||
|
GENERATE_PERLMOD = NO |
||||
|
PERLMOD_LATEX = NO |
||||
|
PERLMOD_PRETTY = YES |
||||
|
PERLMOD_MAKEVAR_PREFIX = |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Configuration options related to the preprocessor |
||||
|
#--------------------------------------------------------------------------- |
||||
|
ENABLE_PREPROCESSING = YES |
||||
|
MACRO_EXPANSION = NO |
||||
|
EXPAND_ONLY_PREDEF = NO |
||||
|
SEARCH_INCLUDES = YES |
||||
|
INCLUDE_PATH = |
||||
|
INCLUDE_FILE_PATTERNS = |
||||
|
PREDEFINED = |
||||
|
EXPAND_AS_DEFINED = |
||||
|
SKIP_FUNCTION_MACROS = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Configuration::additions related to external references |
||||
|
#--------------------------------------------------------------------------- |
||||
|
TAGFILES = |
||||
|
GENERATE_TAGFILE = tp4_comptesbancaires.tag |
||||
|
ALLEXTERNALS = NO |
||||
|
EXTERNAL_GROUPS = YES |
||||
|
PERL_PATH = /usr/bin/perl |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Configuration options related to the dot tool |
||||
|
#--------------------------------------------------------------------------- |
||||
|
CLASS_DIAGRAMS = YES |
||||
|
HIDE_UNDOC_RELATIONS = YES |
||||
|
HAVE_DOT = NO |
||||
|
CLASS_GRAPH = YES |
||||
|
COLLABORATION_GRAPH = YES |
||||
|
GROUP_GRAPHS = YES |
||||
|
UML_LOOK = NO |
||||
|
TEMPLATE_RELATIONS = NO |
||||
|
INCLUDE_GRAPH = YES |
||||
|
INCLUDED_BY_GRAPH = YES |
||||
|
CALL_GRAPH = NO |
||||
|
GRAPHICAL_HIERARCHY = YES |
||||
|
DIRECTORY_GRAPH = YES |
||||
|
DOT_IMAGE_FORMAT = png |
||||
|
DOT_PATH = |
||||
|
DOTFILE_DIRS = |
||||
|
MAX_DOT_GRAPH_WIDTH = 1024 |
||||
|
MAX_DOT_GRAPH_HEIGHT = 1024 |
||||
|
MAX_DOT_GRAPH_DEPTH = 1000 |
||||
|
DOT_TRANSPARENT = NO |
||||
|
DOT_MULTI_TARGETS = NO |
||||
|
GENERATE_LEGEND = YES |
||||
|
DOT_CLEANUP = YES |
||||
|
#--------------------------------------------------------------------------- |
||||
|
# Configuration::additions related to the search engine |
||||
|
#--------------------------------------------------------------------------- |
||||
|
SEARCHENGINE = NO |
||||
@ -0,0 +1,167 @@ |
|||||
|
Basic Installation |
||||
|
================== |
||||
|
|
||||
|
These are generic installation instructions. |
||||
|
|
||||
|
The `configure' shell script attempts to guess correct values for |
||||
|
various system-dependent variables used during compilation. It uses |
||||
|
those values to create a `Makefile' in each directory of the package. |
||||
|
It may also create one or more `.h' files containing system-dependent |
||||
|
definitions. Finally, it creates a shell script `config.status' that |
||||
|
you can run in the future to recreate the current configuration, a file |
||||
|
`config.cache' that saves the results of its tests to speed up |
||||
|
reconfiguring, and a file `config.log' containing compiler output |
||||
|
(useful mainly for debugging `configure'). |
||||
|
|
||||
|
If you need to do unusual things to compile the package, please try |
||||
|
to figure out how `configure' could check whether to do them, and mail |
||||
|
diffs or instructions to the address given in the `README' so they can |
||||
|
be considered for the next release. If at some point `config.cache' |
||||
|
contains results you don't want to keep, you may remove or edit it. |
||||
|
|
||||
|
The file `configure.in' is used to create `configure' by a program |
||||
|
called `autoconf'. You only need `configure.in' if you want to change |
||||
|
it or regenerate `configure' using a newer version of `autoconf'. |
||||
|
|
||||
|
The simplest way to compile this package is: |
||||
|
|
||||
|
1. `cd' to the directory containing the package's source code and type |
||||
|
`./configure' to configure the package for your system. If you're |
||||
|
using `csh' on an old version of System V, you might need to type |
||||
|
`sh ./configure' instead to prevent `csh' from trying to execute |
||||
|
`configure' itself. |
||||
|
|
||||
|
Running `configure' takes a while. While running, it prints some |
||||
|
messages telling which features it is checking for. |
||||
|
|
||||
|
2. Type `make' to compile the package. |
||||
|
|
||||
|
3. Type `make install' to install the programs and any data files and |
||||
|
documentation. |
||||
|
|
||||
|
4. You can remove the program binaries and object files from the |
||||
|
source code directory by typing `make clean'. |
||||
|
|
||||
|
Compilers and Options |
||||
|
===================== |
||||
|
|
||||
|
Some systems require unusual options for compilation or linking that |
||||
|
the `configure' script does not know about. You can give `configure' |
||||
|
initial values for variables by setting them in the environment. Using |
||||
|
a Bourne-compatible shell, you can do that on the command line like |
||||
|
this: |
||||
|
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure |
||||
|
|
||||
|
Or on systems that have the `env' program, you can do it like this: |
||||
|
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure |
||||
|
|
||||
|
Compiling For Multiple Architectures |
||||
|
==================================== |
||||
|
|
||||
|
You can compile the package for more than one kind of computer at the |
||||
|
same time, by placing the object files for each architecture in their |
||||
|
own directory. To do this, you must use a version of `make' that |
||||
|
supports the `VPATH' variable, such as GNU `make'. `cd' to the |
||||
|
directory where you want the object files and executables to go and run |
||||
|
the `configure' script. `configure' automatically checks for the |
||||
|
source code in the directory that `configure' is in and in `..'. |
||||
|
|
||||
|
If you have to use a `make' that does not supports the `VPATH' |
||||
|
variable, you have to compile the package for one architecture at a time |
||||
|
in the source code directory. After you have installed the package for |
||||
|
one architecture, use `make distclean' before reconfiguring for another |
||||
|
architecture. |
||||
|
|
||||
|
Installation Names |
||||
|
================== |
||||
|
|
||||
|
By default, `make install' will install the package's files in |
||||
|
`/usr/local/bin', `/usr/local/man', etc. You can specify an |
||||
|
installation prefix other than `/usr/local' by giving `configure' the |
||||
|
option `--prefix=PATH'. |
||||
|
|
||||
|
You can specify separate installation prefixes for |
||||
|
architecture-specific files and architecture-independent files. If you |
||||
|
give `configure' the option `--exec-prefix=PATH', the package will use |
||||
|
PATH as the prefix for installing programs and libraries. |
||||
|
Documentation and other data files will still use the regular prefix. |
||||
|
|
||||
|
If the package supports it, you can cause programs to be installed |
||||
|
with an extra prefix or suffix on their names by giving `configure' the |
||||
|
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. |
||||
|
|
||||
|
Optional Features |
||||
|
================= |
||||
|
|
||||
|
Some packages pay attention to `--enable-FEATURE' options to |
||||
|
`configure', where FEATURE indicates an optional part of the package. |
||||
|
They may also pay attention to `--with-PACKAGE' options, where PACKAGE |
||||
|
is something like `gnu-as' or `x' (for the X Window System). The |
||||
|
`README' should mention any `--enable-' and `--with-' options that the |
||||
|
package recognizes. |
||||
|
|
||||
|
For packages that use the X Window System, `configure' can usually |
||||
|
find the X include and library files automatically, but if it doesn't, |
||||
|
you can use the `configure' options `--x-includes=DIR' and |
||||
|
`--x-libraries=DIR' to specify their locations. |
||||
|
|
||||
|
Specifying the System Type |
||||
|
========================== |
||||
|
|
||||
|
There may be some features `configure' can not figure out |
||||
|
automatically, but needs to determine by the type of host the package |
||||
|
will run on. Usually `configure' can figure that out, but if it prints |
||||
|
a message saying it can not guess the host type, give it the |
||||
|
`--host=TYPE' option. TYPE can either be a short name for the system |
||||
|
type, such as `sun4', or a canonical name with three fields: |
||||
|
CPU-COMPANY-SYSTEM |
||||
|
|
||||
|
See the file `config.sub' for the possible values of each field. If |
||||
|
`config.sub' isn't included in this package, then this package doesn't |
||||
|
need to know the host type. |
||||
|
|
||||
|
If you are building compiler tools for cross-compiling, you can also |
||||
|
use the `--target=TYPE' option to select the type of system they will |
||||
|
produce code for and the `--build=TYPE' option to select the type of |
||||
|
system on which you are compiling the package. |
||||
|
|
||||
|
Sharing Defaults |
||||
|
================ |
||||
|
|
||||
|
If you want to set default values for `configure' scripts to share, |
||||
|
you can create a site shell script called `config.site' that gives |
||||
|
default values for variables like `CC', `cache_file', and `prefix'. |
||||
|
`configure' looks for `PREFIX/share/config.site' if it exists, then |
||||
|
`PREFIX/etc/config.site' if it exists. Or, you can set the |
||||
|
`CONFIG_SITE' environment variable to the location of the site script. |
||||
|
A warning: not all `configure' scripts look for a site script. |
||||
|
|
||||
|
Operation Controls |
||||
|
================== |
||||
|
|
||||
|
`configure' recognizes the following options to control how it |
||||
|
operates. |
||||
|
|
||||
|
`--cache-file=FILE' |
||||
|
Use and save the results of the tests in FILE instead of |
||||
|
`./config.cache'. Set FILE to `/dev/null' to disable caching, for |
||||
|
debugging `configure'. |
||||
|
|
||||
|
`--help' |
||||
|
Print a summary of the options to `configure', and exit. |
||||
|
|
||||
|
`--quiet' |
||||
|
`--silent' |
||||
|
`-q' |
||||
|
Do not print messages saying which checks are being made. |
||||
|
|
||||
|
`--srcdir=DIR' |
||||
|
Look for the package's source code in directory DIR. Usually |
||||
|
`configure' can determine that directory automatically. |
||||
|
|
||||
|
`--version' |
||||
|
Print the version of Autoconf used to generate the `configure' |
||||
|
script, and exit. |
||||
|
|
||||
|
`configure' also accepts some other, not widely useful, options. |
||||
|
|
||||
@ -0,0 +1,5 @@ |
|||||
|
# not a GNU package. You can remove this line, if
|
||||
|
# have all needed files, that a GNU package needs
|
||||
|
AUTOMAKE_OPTIONS = foreign 1.4 |
||||
|
|
||||
|
SUBDIRS = src |
||||
@ -0,0 +1,8 @@ |
|||||
|
default: all |
||||
|
|
||||
|
all: |
||||
|
aclocal |
||||
|
autoheader |
||||
|
automake |
||||
|
autoconf |
||||
|
|
||||
@ -0,0 +1,612 @@ |
|||||
|
# Makefile.in generated by automake 1.9.6 from Makefile.am.
|
||||
|
# @configure_input@
|
||||
|
|
||||
|
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
|
# 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
# This Makefile.in is free software; the Free Software Foundation
|
||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||
|
# with or without modifications, as long as this notice is preserved.
|
||||
|
|
||||
|
# This program is distributed in the hope that it will be useful,
|
||||
|
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
|
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
|
# PARTICULAR PURPOSE.
|
||||
|
|
||||
|
@SET_MAKE@ |
||||
|
srcdir = @srcdir@ |
||||
|
top_srcdir = @top_srcdir@ |
||||
|
VPATH = @srcdir@ |
||||
|
pkgdatadir = $(datadir)/@PACKAGE@ |
||||
|
pkglibdir = $(libdir)/@PACKAGE@ |
||||
|
pkgincludedir = $(includedir)/@PACKAGE@ |
||||
|
top_builddir = . |
||||
|
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd |
||||
|
INSTALL = @INSTALL@ |
||||
|
install_sh_DATA = $(install_sh) -c -m 644 |
||||
|
install_sh_PROGRAM = $(install_sh) -c |
||||
|
install_sh_SCRIPT = $(install_sh) -c |
||||
|
INSTALL_HEADER = $(INSTALL_DATA) |
||||
|
transform = $(program_transform_name) |
||||
|
NORMAL_INSTALL = : |
||||
|
PRE_INSTALL = : |
||||
|
POST_INSTALL = : |
||||
|
NORMAL_UNINSTALL = : |
||||
|
PRE_UNINSTALL = : |
||||
|
POST_UNINSTALL = : |
||||
|
build_triplet = @build@ |
||||
|
host_triplet = @host@ |
||||
|
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
|
||||
|
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
|
||||
|
$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
|
||||
|
TODO config.guess config.sub depcomp install-sh ltmain.sh \
|
||||
|
missing mkinstalldirs |
||||
|
subdir = . |
||||
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
||||
|
am__aclocal_m4_deps = $(top_srcdir)/configure.in |
||||
|
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
|
$(ACLOCAL_M4) |
||||
|
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
|
configure.lineno configure.status.lineno |
||||
|
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs |
||||
|
CONFIG_HEADER = config.h |
||||
|
CONFIG_CLEAN_FILES = |
||||
|
SOURCES = |
||||
|
DIST_SOURCES = |
||||
|
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
|
||||
|
html-recursive info-recursive install-data-recursive \
|
||||
|
install-exec-recursive install-info-recursive \
|
||||
|
install-recursive installcheck-recursive installdirs-recursive \
|
||||
|
pdf-recursive ps-recursive uninstall-info-recursive \
|
||||
|
uninstall-recursive |
||||
|
ETAGS = etags |
||||
|
CTAGS = ctags |
||||
|
DIST_SUBDIRS = $(SUBDIRS) |
||||
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
||||
|
distdir = $(PACKAGE)-$(VERSION) |
||||
|
top_distdir = $(distdir) |
||||
|
am__remove_distdir = \
|
||||
|
{ test ! -d $(distdir) \
|
||||
|
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||
|
&& rm -fr $(distdir); }; } |
||||
|
DIST_ARCHIVES = $(distdir).tar.gz |
||||
|
GZIP_ENV = --best |
||||
|
distuninstallcheck_listfiles = find . -type f -print |
||||
|
distcleancheck_listfiles = find . -type f -print |
||||
|
ACLOCAL = @ACLOCAL@ |
||||
|
AMDEP_FALSE = @AMDEP_FALSE@ |
||||
|
AMDEP_TRUE = @AMDEP_TRUE@ |
||||
|
AMTAR = @AMTAR@ |
||||
|
AR = @AR@ |
||||
|
AUTOCONF = @AUTOCONF@ |
||||
|
AUTOHEADER = @AUTOHEADER@ |
||||
|
AUTOMAKE = @AUTOMAKE@ |
||||
|
AWK = @AWK@ |
||||
|
CC = @CC@ |
||||
|
CCDEPMODE = @CCDEPMODE@ |
||||
|
CFLAGS = @CFLAGS@ |
||||
|
CPP = @CPP@ |
||||
|
CPPFLAGS = @CPPFLAGS@ |
||||
|
CXX = @CXX@ |
||||
|
CXXCPP = @CXXCPP@ |
||||
|
CXXDEPMODE = @CXXDEPMODE@ |
||||
|
CXXFLAGS = @CXXFLAGS@ |
||||
|
CYGPATH_W = @CYGPATH_W@ |
||||
|
DEFS = @DEFS@ |
||||
|
DEPDIR = @DEPDIR@ |
||||
|
ECHO = @ECHO@ |
||||
|
ECHO_C = @ECHO_C@ |
||||
|
ECHO_N = @ECHO_N@ |
||||
|
ECHO_T = @ECHO_T@ |
||||
|
EGREP = @EGREP@ |
||||
|
EXEEXT = @EXEEXT@ |
||||
|
F77 = @F77@ |
||||
|
FFLAGS = @FFLAGS@ |
||||
|
INSTALL_DATA = @INSTALL_DATA@ |
||||
|
INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
||||
|
INSTALL_SCRIPT = @INSTALL_SCRIPT@ |
||||
|
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ |
||||
|
LDFLAGS = @LDFLAGS@ |
||||
|
LIBOBJS = @LIBOBJS@ |
||||
|
LIBS = @LIBS@ |
||||
|
LIBTOOL = @LIBTOOL@ |
||||
|
LN_S = @LN_S@ |
||||
|
LTLIBOBJS = @LTLIBOBJS@ |
||||
|
MAKEINFO = @MAKEINFO@ |
||||
|
OBJEXT = @OBJEXT@ |
||||
|
PACKAGE = @PACKAGE@ |
||||
|
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ |
||||
|
PACKAGE_NAME = @PACKAGE_NAME@ |
||||
|
PACKAGE_STRING = @PACKAGE_STRING@ |
||||
|
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
||||
|
PACKAGE_VERSION = @PACKAGE_VERSION@ |
||||
|
PATH_SEPARATOR = @PATH_SEPARATOR@ |
||||
|
RANLIB = @RANLIB@ |
||||
|
SET_MAKE = @SET_MAKE@ |
||||
|
SHELL = @SHELL@ |
||||
|
STRIP = @STRIP@ |
||||
|
VERSION = @VERSION@ |
||||
|
ac_ct_AR = @ac_ct_AR@ |
||||
|
ac_ct_CC = @ac_ct_CC@ |
||||
|
ac_ct_CXX = @ac_ct_CXX@ |
||||
|
ac_ct_F77 = @ac_ct_F77@ |
||||
|
ac_ct_RANLIB = @ac_ct_RANLIB@ |
||||
|
ac_ct_STRIP = @ac_ct_STRIP@ |
||||
|
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ |
||||
|
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ |
||||
|
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ |
||||
|
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ |
||||
|
am__include = @am__include@ |
||||
|
am__leading_dot = @am__leading_dot@ |
||||
|
am__quote = @am__quote@ |
||||
|
am__tar = @am__tar@ |
||||
|
am__untar = @am__untar@ |
||||
|
bindir = @bindir@ |
||||
|
build = @build@ |
||||
|
build_alias = @build_alias@ |
||||
|
build_cpu = @build_cpu@ |
||||
|
build_os = @build_os@ |
||||
|
build_vendor = @build_vendor@ |
||||
|
datadir = @datadir@ |
||||
|
exec_prefix = @exec_prefix@ |
||||
|
host = @host@ |
||||
|
host_alias = @host_alias@ |
||||
|
host_cpu = @host_cpu@ |
||||
|
host_os = @host_os@ |
||||
|
host_vendor = @host_vendor@ |
||||
|
includedir = @includedir@ |
||||
|
infodir = @infodir@ |
||||
|
install_sh = @install_sh@ |
||||
|
libdir = @libdir@ |
||||
|
libexecdir = @libexecdir@ |
||||
|
localstatedir = @localstatedir@ |
||||
|
mandir = @mandir@ |
||||
|
mkdir_p = @mkdir_p@ |
||||
|
oldincludedir = @oldincludedir@ |
||||
|
prefix = @prefix@ |
||||
|
program_transform_name = @program_transform_name@ |
||||
|
sbindir = @sbindir@ |
||||
|
sharedstatedir = @sharedstatedir@ |
||||
|
sysconfdir = @sysconfdir@ |
||||
|
target_alias = @target_alias@ |
||||
|
|
||||
|
# not a GNU package. You can remove this line, if
|
||||
|
# have all needed files, that a GNU package needs
|
||||
|
AUTOMAKE_OPTIONS = foreign 1.4 |
||||
|
SUBDIRS = src |
||||
|
all: config.h |
||||
|
$(MAKE) $(AM_MAKEFLAGS) all-recursive |
||||
|
|
||||
|
.SUFFIXES: |
||||
|
am--refresh: |
||||
|
@: |
||||
|
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) |
||||
|
@for dep in $?; do \
|
||||
|
case '$(am__configure_deps)' in \
|
||||
|
*$$dep*) \
|
||||
|
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
|
||||
|
cd $(srcdir) && $(AUTOMAKE) --foreign \
|
||||
|
&& exit 0; \
|
||||
|
exit 1;; \
|
||||
|
esac; \
|
||||
|
done; \
|
||||
|
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
|
||||
|
cd $(top_srcdir) && \
|
||||
|
$(AUTOMAKE) --foreign Makefile |
||||
|
.PRECIOUS: Makefile |
||||
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
||||
|
@case '$?' in \
|
||||
|
*config.status*) \
|
||||
|
echo ' $(SHELL) ./config.status'; \
|
||||
|
$(SHELL) ./config.status;; \
|
||||
|
*) \
|
||||
|
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
|
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
|
esac; |
||||
|
|
||||
|
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) |
||||
|
$(SHELL) ./config.status --recheck |
||||
|
|
||||
|
$(top_srcdir)/configure: $(am__configure_deps) |
||||
|
cd $(srcdir) && $(AUTOCONF) |
||||
|
$(ACLOCAL_M4): $(am__aclocal_m4_deps) |
||||
|
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) |
||||
|
|
||||
|
config.h: stamp-h1 |
||||
|
@if test ! -f $@; then \
|
||||
|
rm -f stamp-h1; \
|
||||
|
$(MAKE) stamp-h1; \
|
||||
|
else :; fi |
||||
|
|
||||
|
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status |
||||
|
@rm -f stamp-h1 |
||||
|
cd $(top_builddir) && $(SHELL) ./config.status config.h |
||||
|
$(srcdir)/config.h.in: $(am__configure_deps) |
||||
|
cd $(top_srcdir) && $(AUTOHEADER) |
||||
|
rm -f stamp-h1 |
||||
|
touch $@ |
||||
|
|
||||
|
distclean-hdr: |
||||
|
-rm -f config.h stamp-h1 |
||||
|
|
||||
|
mostlyclean-libtool: |
||||
|
-rm -f *.lo |
||||
|
|
||||
|
clean-libtool: |
||||
|
-rm -rf .libs _libs |
||||
|
|
||||
|
distclean-libtool: |
||||
|
-rm -f libtool |
||||
|
uninstall-info-am: |
||||
|
|
||||
|
# This directory's subdirectories are mostly independent; you can cd
|
||||
|
# into them and run `make' without going through this Makefile.
|
||||
|
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
|
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
|
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
|
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
|
$(RECURSIVE_TARGETS): |
||||
|
@failcom='exit 1'; \
|
||||
|
for f in x $$MAKEFLAGS; do \
|
||||
|
case $$f in \
|
||||
|
*=* | --[!k]*);; \
|
||||
|
*k*) failcom='fail=yes';; \
|
||||
|
esac; \
|
||||
|
done; \
|
||||
|
dot_seen=no; \
|
||||
|
target=`echo $@ | sed s/-recursive//`; \
|
||||
|
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
|
echo "Making $$target in $$subdir"; \
|
||||
|
if test "$$subdir" = "."; then \
|
||||
|
dot_seen=yes; \
|
||||
|
local_target="$$target-am"; \
|
||||
|
else \
|
||||
|
local_target="$$target"; \
|
||||
|
fi; \
|
||||
|
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|
|| eval $$failcom; \
|
||||
|
done; \
|
||||
|
if test "$$dot_seen" = "no"; then \
|
||||
|
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
|
fi; test -z "$$fail" |
||||
|
|
||||
|
mostlyclean-recursive clean-recursive distclean-recursive \ |
||||
|
maintainer-clean-recursive: |
||||
|
@failcom='exit 1'; \
|
||||
|
for f in x $$MAKEFLAGS; do \
|
||||
|
case $$f in \
|
||||
|
*=* | --[!k]*);; \
|
||||
|
*k*) failcom='fail=yes';; \
|
||||
|
esac; \
|
||||
|
done; \
|
||||
|
dot_seen=no; \
|
||||
|
case "$@" in \
|
||||
|
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
|
||||
|
*) list='$(SUBDIRS)' ;; \
|
||||
|
esac; \
|
||||
|
rev=''; for subdir in $$list; do \
|
||||
|
if test "$$subdir" = "."; then :; else \
|
||||
|
rev="$$subdir $$rev"; \
|
||||
|
fi; \
|
||||
|
done; \
|
||||
|
rev="$$rev ."; \
|
||||
|
target=`echo $@ | sed s/-recursive//`; \
|
||||
|
for subdir in $$rev; do \
|
||||
|
echo "Making $$target in $$subdir"; \
|
||||
|
if test "$$subdir" = "."; then \
|
||||
|
local_target="$$target-am"; \
|
||||
|
else \
|
||||
|
local_target="$$target"; \
|
||||
|
fi; \
|
||||
|
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|
|| eval $$failcom; \
|
||||
|
done && test -z "$$fail" |
||||
|
tags-recursive: |
||||
|
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
|
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
|
done |
||||
|
ctags-recursive: |
||||
|
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
|
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
|
||||
|
done |
||||
|
|
||||
|
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) |
||||
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
|
unique=`for i in $$list; do \
|
||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
|
done | \
|
||||
|
$(AWK) ' { files[$$0] = 1; } \
|
||||
|
END { for (i in files) print i; }'`; \
|
||||
|
mkid -fID $$unique |
||||
|
tags: TAGS |
||||
|
|
||||
|
TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ |
||||
|
$(TAGS_FILES) $(LISP) |
||||
|
tags=; \
|
||||
|
here=`pwd`; \
|
||||
|
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
|
||||
|
include_option=--etags-include; \
|
||||
|
empty_fix=.; \
|
||||
|
else \
|
||||
|
include_option=--include; \
|
||||
|
empty_fix=; \
|
||||
|
fi; \
|
||||
|
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
|
if test "$$subdir" = .; then :; else \
|
||||
|
test ! -f $$subdir/TAGS || \
|
||||
|
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
|
||||
|
fi; \
|
||||
|
done; \
|
||||
|
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
|
unique=`for i in $$list; do \
|
||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
|
done | \
|
||||
|
$(AWK) ' { files[$$0] = 1; } \
|
||||
|
END { for (i in files) print i; }'`; \
|
||||
|
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
|
test -n "$$unique" || unique=$$empty_fix; \
|
||||
|
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
|
$$tags $$unique; \
|
||||
|
fi |
||||
|
ctags: CTAGS |
||||
|
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ |
||||
|
$(TAGS_FILES) $(LISP) |
||||
|
tags=; \
|
||||
|
here=`pwd`; \
|
||||
|
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
|
unique=`for i in $$list; do \
|
||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
|
done | \
|
||||
|
$(AWK) ' { files[$$0] = 1; } \
|
||||
|
END { for (i in files) print i; }'`; \
|
||||
|
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
|
$$tags $$unique |
||||
|
|
||||
|
GTAGS: |
||||
|
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
|
&& cd $(top_srcdir) \
|
||||
|
&& gtags -i $(GTAGS_ARGS) $$here |
||||
|
|
||||
|
distclean-tags: |
||||
|
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags |
||||
|
|
||||
|
distdir: $(DISTFILES) |
||||
|
$(am__remove_distdir) |
||||
|
mkdir $(distdir) |
||||
|
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
|
||||
|
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
|
||||
|
list='$(DISTFILES)'; for file in $$list; do \
|
||||
|
case $$file in \
|
||||
|
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
|
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
|
||||
|
esac; \
|
||||
|
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
|
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
|
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
|
||||
|
dir="/$$dir"; \
|
||||
|
$(mkdir_p) "$(distdir)$$dir"; \
|
||||
|
else \
|
||||
|
dir=''; \
|
||||
|
fi; \
|
||||
|
if test -d $$d/$$file; then \
|
||||
|
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
|
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
|
fi; \
|
||||
|
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
|
else \
|
||||
|
test -f $(distdir)/$$file \
|
||||
|
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|
|| exit 1; \
|
||||
|
fi; \
|
||||
|
done |
||||
|
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
|
if test "$$subdir" = .; then :; else \
|
||||
|
test -d "$(distdir)/$$subdir" \
|
||||
|
|| $(mkdir_p) "$(distdir)/$$subdir" \
|
||||
|
|| exit 1; \
|
||||
|
distdir=`$(am__cd) $(distdir) && pwd`; \
|
||||
|
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
|
||||
|
(cd $$subdir && \
|
||||
|
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
|
top_distdir="$$top_distdir" \
|
||||
|
distdir="$$distdir/$$subdir" \
|
||||
|
distdir) \
|
||||
|
|| exit 1; \
|
||||
|
fi; \
|
||||
|
done |
||||
|
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
|
||||
|
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
|
||||
|
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
|
||||
|
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|
||||
|
|| chmod -R a+r $(distdir) |
||||
|
dist-gzip: distdir |
||||
|
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz |
||||
|
$(am__remove_distdir) |
||||
|
|
||||
|
dist-bzip2: distdir |
||||
|
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 |
||||
|
$(am__remove_distdir) |
||||
|
|
||||
|
dist-tarZ: distdir |
||||
|
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z |
||||
|
$(am__remove_distdir) |
||||
|
|
||||
|
dist-shar: distdir |
||||
|
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz |
||||
|
$(am__remove_distdir) |
||||
|
|
||||
|
dist-zip: distdir |
||||
|
-rm -f $(distdir).zip |
||||
|
zip -rq $(distdir).zip $(distdir) |
||||
|
$(am__remove_distdir) |
||||
|
|
||||
|
dist dist-all: distdir |
||||
|
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz |
||||
|
$(am__remove_distdir) |
||||
|
|
||||
|
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
|
# it guarantees that the distribution is self-contained by making another
|
||||
|
# tarfile.
|
||||
|
distcheck: dist |
||||
|
case '$(DIST_ARCHIVES)' in \
|
||||
|
*.tar.gz*) \
|
||||
|
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
|
||||
|
*.tar.bz2*) \
|
||||
|
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
|
*.tar.Z*) \
|
||||
|
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||
|
*.shar.gz*) \
|
||||
|
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
|
||||
|
*.zip*) \
|
||||
|
unzip $(distdir).zip ;;\
|
||||
|
esac |
||||
|
chmod -R a-w $(distdir); chmod a+w $(distdir) |
||||
|
mkdir $(distdir)/_build |
||||
|
mkdir $(distdir)/_inst |
||||
|
chmod a-w $(distdir) |
||||
|
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
|
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
|
&& cd $(distdir)/_build \
|
||||
|
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
|
||||
|
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
|
||||
|
distuninstallcheck \
|
||||
|
&& chmod -R a-w "$$dc_install_base" \
|
||||
|
&& ({ \
|
||||
|
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
|
||||
|
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
|
||||
|
} || { rm -rf "$$dc_destdir"; exit 1; }) \
|
||||
|
&& rm -rf "$$dc_destdir" \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) dist \
|
||||
|
&& rm -rf $(DIST_ARCHIVES) \
|
||||
|
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck |
||||
|
$(am__remove_distdir) |
||||
|
@(echo "$(distdir) archives ready for distribution: "; \
|
||||
|
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
|
||||
|
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' |
||||
|
distuninstallcheck: |
||||
|
@cd $(distuninstallcheck_dir) \
|
||||
|
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|
||||
|
|| { echo "ERROR: files left after uninstall:" ; \
|
||||
|
if test -n "$(DESTDIR)"; then \
|
||||
|
echo " (check DESTDIR support)"; \
|
||||
|
fi ; \
|
||||
|
$(distuninstallcheck_listfiles) ; \
|
||||
|
exit 1; } >&2 |
||||
|
distcleancheck: distclean |
||||
|
@if test '$(srcdir)' = . ; then \
|
||||
|
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
|
||||
|
exit 1 ; \
|
||||
|
fi |
||||
|
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|
||||
|
|| { echo "ERROR: files left in build directory after distclean:" ; \
|
||||
|
$(distcleancheck_listfiles) ; \
|
||||
|
exit 1; } >&2 |
||||
|
check-am: all-am |
||||
|
check: check-recursive |
||||
|
all-am: Makefile config.h |
||||
|
installdirs: installdirs-recursive |
||||
|
installdirs-am: |
||||
|
install: install-recursive |
||||
|
install-exec: install-exec-recursive |
||||
|
install-data: install-data-recursive |
||||
|
uninstall: uninstall-recursive |
||||
|
|
||||
|
install-am: all-am |
||||
|
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am |
||||
|
|
||||
|
installcheck: installcheck-recursive |
||||
|
install-strip: |
||||
|
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
|
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
|
`test -z '$(STRIP)' || \
|
||||
|
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install |
||||
|
mostlyclean-generic: |
||||
|
|
||||
|
clean-generic: |
||||
|
|
||||
|
distclean-generic: |
||||
|
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) |
||||
|
|
||||
|
maintainer-clean-generic: |
||||
|
@echo "This command is intended for maintainers to use" |
||||
|
@echo "it deletes files that may require special tools to rebuild." |
||||
|
clean: clean-recursive |
||||
|
|
||||
|
clean-am: clean-generic clean-libtool mostlyclean-am |
||||
|
|
||||
|
distclean: distclean-recursive |
||||
|
-rm -f $(am__CONFIG_DISTCLEAN_FILES) |
||||
|
-rm -f Makefile |
||||
|
distclean-am: clean-am distclean-generic distclean-hdr \ |
||||
|
distclean-libtool distclean-tags |
||||
|
|
||||
|
dvi: dvi-recursive |
||||
|
|
||||
|
dvi-am: |
||||
|
|
||||
|
html: html-recursive |
||||
|
|
||||
|
info: info-recursive |
||||
|
|
||||
|
info-am: |
||||
|
|
||||
|
install-data-am: |
||||
|
|
||||
|
install-exec-am: |
||||
|
|
||||
|
install-info: install-info-recursive |
||||
|
|
||||
|
install-man: |
||||
|
|
||||
|
installcheck-am: |
||||
|
|
||||
|
maintainer-clean: maintainer-clean-recursive |
||||
|
-rm -f $(am__CONFIG_DISTCLEAN_FILES) |
||||
|
-rm -rf $(top_srcdir)/autom4te.cache |
||||
|
-rm -f Makefile |
||||
|
maintainer-clean-am: distclean-am maintainer-clean-generic |
||||
|
|
||||
|
mostlyclean: mostlyclean-recursive |
||||
|
|
||||
|
mostlyclean-am: mostlyclean-generic mostlyclean-libtool |
||||
|
|
||||
|
pdf: pdf-recursive |
||||
|
|
||||
|
pdf-am: |
||||
|
|
||||
|
ps: ps-recursive |
||||
|
|
||||
|
ps-am: |
||||
|
|
||||
|
uninstall-am: uninstall-info-am |
||||
|
|
||||
|
uninstall-info: uninstall-info-recursive |
||||
|
|
||||
|
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ |
||||
|
check-am clean clean-generic clean-libtool clean-recursive \
|
||||
|
ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
|
||||
|
dist-shar dist-tarZ dist-zip distcheck distclean \
|
||||
|
distclean-generic distclean-hdr distclean-libtool \
|
||||
|
distclean-recursive distclean-tags distcleancheck distdir \
|
||||
|
distuninstallcheck dvi dvi-am html html-am info info-am \
|
||||
|
install install-am install-data install-data-am install-exec \
|
||||
|
install-exec-am install-info install-info-am install-man \
|
||||
|
install-strip installcheck installcheck-am installdirs \
|
||||
|
installdirs-am maintainer-clean maintainer-clean-generic \
|
||||
|
maintainer-clean-recursive mostlyclean mostlyclean-generic \
|
||||
|
mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \
|
||||
|
tags tags-recursive uninstall uninstall-am uninstall-info-am |
||||
|
|
||||
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
.NOEXPORT: |
||||
@ -0,0 +1 @@ |
|||||
|
On peut dire que le type compte n'est pas absolument polymorphe car ce n'est pas un type abstrait: toute les methodes ont une implémentation, de plus ele ne sont pas toute surchargées. Il y a donc une partie de l'implémentation qui est propre à la classe Compte, elle n'est donc pas absolument polymorphe |
||||
@ -0,0 +1 @@ |
|||||
|
La totalité de l'énoncé a été traité |
||||
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,55 @@ |
|||||
|
/* config.h.in. Generated from configure.in by autoheader. */ |
||||
|
|
||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */ |
||||
|
#undef HAVE_DLFCN_H |
||||
|
|
||||
|
/* Define to 1 if you have the <inttypes.h> header file. */ |
||||
|
#undef HAVE_INTTYPES_H |
||||
|
|
||||
|
/* Define to 1 if you have the <memory.h> header file. */ |
||||
|
#undef HAVE_MEMORY_H |
||||
|
|
||||
|
/* Define to 1 if you have the <stdint.h> header file. */ |
||||
|
#undef HAVE_STDINT_H |
||||
|
|
||||
|
/* Define to 1 if you have the <stdlib.h> header file. */ |
||||
|
#undef HAVE_STDLIB_H |
||||
|
|
||||
|
/* Define to 1 if you have the <strings.h> header file. */ |
||||
|
#undef HAVE_STRINGS_H |
||||
|
|
||||
|
/* Define to 1 if you have the <string.h> header file. */ |
||||
|
#undef HAVE_STRING_H |
||||
|
|
||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */ |
||||
|
#undef HAVE_SYS_STAT_H |
||||
|
|
||||
|
/* Define to 1 if you have the <sys/types.h> header file. */ |
||||
|
#undef HAVE_SYS_TYPES_H |
||||
|
|
||||
|
/* Define to 1 if you have the <unistd.h> header file. */ |
||||
|
#undef HAVE_UNISTD_H |
||||
|
|
||||
|
/* Name of package */ |
||||
|
#undef PACKAGE |
||||
|
|
||||
|
/* Define to the address where bug reports for this package should be sent. */ |
||||
|
#undef PACKAGE_BUGREPORT |
||||
|
|
||||
|
/* Define to the full name of this package. */ |
||||
|
#undef PACKAGE_NAME |
||||
|
|
||||
|
/* Define to the full name and version of this package. */ |
||||
|
#undef PACKAGE_STRING |
||||
|
|
||||
|
/* Define to the one symbol short name of this package. */ |
||||
|
#undef PACKAGE_TARNAME |
||||
|
|
||||
|
/* Define to the version of this package. */ |
||||
|
#undef PACKAGE_VERSION |
||||
|
|
||||
|
/* Define to 1 if you have the ANSI C header files. */ |
||||
|
#undef STDC_HEADERS |
||||
|
|
||||
|
/* Version number of package */ |
||||
|
#undef VERSION |
||||
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,10 @@ |
|||||
|
AC_INIT(configure.in) |
||||
|
|
||||
|
AM_CONFIG_HEADER(config.h) |
||||
|
AM_INIT_AUTOMAKE(tp4_comptesbancaires, 0.1) |
||||
|
|
||||
|
AC_LANG_CPLUSPLUS |
||||
|
AC_PROG_CXX |
||||
|
AM_PROG_LIBTOOL |
||||
|
|
||||
|
AC_OUTPUT(Makefile src/Makefile) |
||||
@ -0,0 +1,441 @@ |
|||||
|
#! /bin/sh |
||||
|
|
||||
|
# depcomp - compile a program generating dependencies as side-effects |
||||
|
# Copyright 1999, 2000 Free Software Foundation, Inc. |
||||
|
|
||||
|
# This program is free software; you can redistribute it and/or modify |
||||
|
# it under the terms of the GNU General Public License as published by |
||||
|
# the Free Software Foundation; either version 2, or (at your option) |
||||
|
# any later version. |
||||
|
|
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU General Public License for more details. |
||||
|
|
||||
|
# You should have received a copy of the GNU General Public License |
||||
|
# along with this program; if not, write to the Free Software |
||||
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
||||
|
# 02111-1307, USA. |
||||
|
|
||||
|
# As a special exception to the GNU General Public License, if you |
||||
|
# distribute this file as part of a program that contains a |
||||
|
# configuration script generated by Autoconf, you may include it under |
||||
|
# the same distribution terms that you use for the rest of that program. |
||||
|
|
||||
|
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. |
||||
|
|
||||
|
if test -z "$depmode" || test -z "$source" || test -z "$object"; then |
||||
|
echo "depcomp: Variables source, object and depmode must be set" 1>&2 |
||||
|
exit 1 |
||||
|
fi |
||||
|
# `libtool' can also be set to `yes' or `no'. |
||||
|
|
||||
|
depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} |
||||
|
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} |
||||
|
|
||||
|
rm -f "$tmpdepfile" |
||||
|
|
||||
|
# Some modes work just like other modes, but use different flags. We |
||||
|
# parameterize here, but still list the modes in the big case below, |
||||
|
# to make depend.m4 easier to write. Note that we *cannot* use a case |
||||
|
# here, because this file can only contain one case statement. |
||||
|
if test "$depmode" = hp; then |
||||
|
# HP compiler uses -M and no extra arg. |
||||
|
gccflag=-M |
||||
|
depmode=gcc |
||||
|
fi |
||||
|
|
||||
|
if test "$depmode" = dashXmstdout; then |
||||
|
# This is just like dashmstdout with a different argument. |
||||
|
dashmflag=-xM |
||||
|
depmode=dashmstdout |
||||
|
fi |
||||
|
|
||||
|
case "$depmode" in |
||||
|
gcc3) |
||||
|
## gcc 3 implements dependency tracking that does exactly what |
||||
|
## we want. Yay! Note: for some reason libtool 1.4 doesn't like |
||||
|
## it if -MD -MP comes after the -MF stuff. Hmm. |
||||
|
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile" |
||||
|
stat=$? |
||||
|
if test $stat -eq 0; then : |
||||
|
else |
||||
|
rm -f "$tmpdepfile" |
||||
|
exit $stat |
||||
|
fi |
||||
|
mv "$tmpdepfile" "$depfile" |
||||
|
;; |
||||
|
|
||||
|
gcc) |
||||
|
## There are various ways to get dependency output from gcc. Here's |
||||
|
## why we pick this rather obscure method: |
||||
|
## - Don't want to use -MD because we'd like the dependencies to end |
||||
|
## up in a subdir. Having to rename by hand is ugly. |
||||
|
## (We might end up doing this anyway to support other compilers.) |
||||
|
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like |
||||
|
## -MM, not -M (despite what the docs say). |
||||
|
## - Using -M directly means running the compiler twice (even worse |
||||
|
## than renaming). |
||||
|
if test -z "$gccflag"; then |
||||
|
gccflag=-MD, |
||||
|
fi |
||||
|
"$@" -Wp,"$gccflag$tmpdepfile" |
||||
|
stat=$? |
||||
|
if test $stat -eq 0; then : |
||||
|
else |
||||
|
rm -f "$tmpdepfile" |
||||
|
exit $stat |
||||
|
fi |
||||
|
rm -f "$depfile" |
||||
|
echo "$object : \\" > "$depfile" |
||||
|
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz |
||||
|
## The second -e expression handles DOS-style file names with drive letters. |
||||
|
sed -e 's/^[^:]*: / /' \ |
||||
|
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" |
||||
|
## This next piece of magic avoids the `deleted header file' problem. |
||||
|
## The problem is that when a header file which appears in a .P file |
||||
|
## is deleted, the dependency causes make to die (because there is |
||||
|
## typically no way to rebuild the header). We avoid this by adding |
||||
|
## dummy dependencies for each header file. Too bad gcc doesn't do |
||||
|
## this for us directly. |
||||
|
tr ' ' ' |
||||
|
' < "$tmpdepfile" | |
||||
|
## Some versions of gcc put a space before the `:'. On the theory |
||||
|
## that the space means something, we add a space to the output as |
||||
|
## well. |
||||
|
## Some versions of the HPUX 10.20 sed can't process this invocation |
||||
|
## correctly. Breaking it into two sed invocations is a workaround. |
||||
|
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" |
||||
|
rm -f "$tmpdepfile" |
||||
|
;; |
||||
|
|
||||
|
hp) |
||||
|
# This case exists only to let depend.m4 do its work. It works by |
||||
|
# looking at the text of this script. This case will never be run, |
||||
|
# since it is checked for above. |
||||
|
exit 1 |
||||
|
;; |
||||
|
|
||||
|
sgi) |
||||
|
if test "$libtool" = yes; then |
||||
|
"$@" "-Wp,-MDupdate,$tmpdepfile" |
||||
|
else |
||||
|
"$@" -MDupdate "$tmpdepfile" |
||||
|
fi |
||||
|
stat=$? |
||||
|
if test $stat -eq 0; then : |
||||
|
else |
||||
|
rm -f "$tmpdepfile" |
||||
|
exit $stat |
||||
|
fi |
||||
|
rm -f "$depfile" |
||||
|
|
||||
|
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files |
||||
|
echo "$object : \\" > "$depfile" |
||||
|
|
||||
|
# Clip off the initial element (the dependent). Don't try to be |
||||
|
# clever and replace this with sed code, as IRIX sed won't handle |
||||
|
# lines with more than a fixed number of characters (4096 in |
||||
|
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; |
||||
|
# the IRIX cc adds comments like `#:fec' to the end of the |
||||
|
# dependency line. |
||||
|
tr ' ' ' |
||||
|
' < "$tmpdepfile" \ |
||||
|
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ |
||||
|
tr ' |
||||
|
' ' ' >> $depfile |
||||
|
echo >> $depfile |
||||
|
|
||||
|
# The second pass generates a dummy entry for each header file. |
||||
|
tr ' ' ' |
||||
|
' < "$tmpdepfile" \ |
||||
|
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ |
||||
|
>> $depfile |
||||
|
else |
||||
|
# The sourcefile does not contain any dependencies, so just |
||||
|
# store a dummy comment line, to avoid errors with the Makefile |
||||
|
# "include basename.Plo" scheme. |
||||
|
echo "#dummy" > "$depfile" |
||||
|
fi |
||||
|
rm -f "$tmpdepfile" |
||||
|
;; |
||||
|
|
||||
|
aix) |
||||
|
# The C for AIX Compiler uses -M and outputs the dependencies |
||||
|
# in a .u file. This file always lives in the current directory. |
||||
|
# Also, the AIX compiler puts `$object:' at the start of each line; |
||||
|
# $object doesn't have directory information. |
||||
|
stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` |
||||
|
tmpdepfile="$stripped.u" |
||||
|
outname="$stripped.o" |
||||
|
if test "$libtool" = yes; then |
||||
|
"$@" -Wc,-M |
||||
|
else |
||||
|
"$@" -M |
||||
|
fi |
||||
|
|
||||
|
stat=$? |
||||
|
if test $stat -eq 0; then : |
||||
|
else |
||||
|
rm -f "$tmpdepfile" |
||||
|
exit $stat |
||||
|
fi |
||||
|
|
||||
|
if test -f "$tmpdepfile"; then |
||||
|
# Each line is of the form `foo.o: dependent.h'. |
||||
|
# Do two passes, one to just change these to |
||||
|
# `$object: dependent.h' and one to simply `dependent.h:'. |
||||
|
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" |
||||
|
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" |
||||
|
else |
||||
|
# The sourcefile does not contain any dependencies, so just |
||||
|
# store a dummy comment line, to avoid errors with the Makefile |
||||
|
# "include basename.Plo" scheme. |
||||
|
echo "#dummy" > "$depfile" |
||||
|
fi |
||||
|
rm -f "$tmpdepfile" |
||||
|
;; |
||||
|
|
||||
|
icc) |
||||
|
# Must come before tru64. |
||||
|
|
||||
|
# Intel's C compiler understands `-MD -MF file'. However |
||||
|
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c |
||||
|
# will fill foo.d with something like |
||||
|
# foo.o: sub/foo.c |
||||
|
# foo.o: sub/foo.h |
||||
|
# which is wrong. We want: |
||||
|
# sub/foo.o: sub/foo.c |
||||
|
# sub/foo.o: sub/foo.h |
||||
|
# sub/foo.c: |
||||
|
# sub/foo.h: |
||||
|
|
||||
|
"$@" -MD -MF "$tmpdepfile" |
||||
|
stat=$? |
||||
|
if test $stat -eq 0; then : |
||||
|
else |
||||
|
rm -f "$tmpdepfile" |
||||
|
exit $stat |
||||
|
fi |
||||
|
rm -f "$depfile" |
||||
|
# Each line is of the form `foo.o: dependent.h'. |
||||
|
# Do two passes, one to just change these to |
||||
|
# `$object: dependent.h' and one to simply `dependent.h:'. |
||||
|
sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" |
||||
|
sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" |
||||
|
rm -f "$tmpdepfile" |
||||
|
;; |
||||
|
|
||||
|
tru64) |
||||
|
# The Tru64 AIX compiler uses -MD to generate dependencies as a side |
||||
|
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. |
||||
|
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put |
||||
|
# dependencies in `foo.d' instead, so we check for that too. |
||||
|
# Subdirectories are respected. |
||||
|
|
||||
|
tmpdepfile1="$object.d" |
||||
|
tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` |
||||
|
if test "$libtool" = yes; then |
||||
|
"$@" -Wc,-MD |
||||
|
else |
||||
|
"$@" -MD |
||||
|
fi |
||||
|
|
||||
|
stat=$? |
||||
|
if test $stat -eq 0; then : |
||||
|
else |
||||
|
rm -f "$tmpdepfile1" "$tmpdepfile2" |
||||
|
exit $stat |
||||
|
fi |
||||
|
|
||||
|
if test -f "$tmpdepfile1"; then |
||||
|
tmpdepfile="$tmpdepfile1" |
||||
|
else |
||||
|
tmpdepfile="$tmpdepfile2" |
||||
|
fi |
||||
|
if test -f "$tmpdepfile"; then |
||||
|
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" |
||||
|
# That's a space and a tab in the []. |
||||
|
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" |
||||
|
else |
||||
|
echo "#dummy" > "$depfile" |
||||
|
fi |
||||
|
rm -f "$tmpdepfile" |
||||
|
;; |
||||
|
|
||||
|
#nosideeffect) |
||||
|
# This comment above is used by automake to tell side-effect |
||||
|
# dependency tracking mechanisms from slower ones. |
||||
|
|
||||
|
dashmstdout) |
||||
|
# Important note: in order to support this mode, a compiler *must* |
||||
|
# always write the proprocessed file to stdout, regardless of -o, |
||||
|
# because we must use -o when running libtool. |
||||
|
test -z "$dashmflag" && dashmflag=-M |
||||
|
( IFS=" " |
||||
|
case " $* " in |
||||
|
*" --mode=compile "*) # this is libtool, let us make it quiet |
||||
|
for arg |
||||
|
do # cycle over the arguments |
||||
|
case "$arg" in |
||||
|
"--mode=compile") |
||||
|
# insert --quiet before "--mode=compile" |
||||
|
set fnord "$@" --quiet |
||||
|
shift # fnord |
||||
|
;; |
||||
|
esac |
||||
|
set fnord "$@" "$arg" |
||||
|
shift # fnord |
||||
|
shift # "$arg" |
||||
|
done |
||||
|
;; |
||||
|
esac |
||||
|
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" |
||||
|
) & |
||||
|
proc=$! |
||||
|
"$@" |
||||
|
stat=$? |
||||
|
wait "$proc" |
||||
|
if test "$stat" != 0; then exit $stat; fi |
||||
|
rm -f "$depfile" |
||||
|
cat < "$tmpdepfile" > "$depfile" |
||||
|
tr ' ' ' |
||||
|
' < "$tmpdepfile" | \ |
||||
|
## Some versions of the HPUX 10.20 sed can't process this invocation |
||||
|
## correctly. Breaking it into two sed invocations is a workaround. |
||||
|
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" |
||||
|
rm -f "$tmpdepfile" |
||||
|
;; |
||||
|
|
||||
|
dashXmstdout) |
||||
|
# This case only exists to satisfy depend.m4. It is never actually |
||||
|
# run, as this mode is specially recognized in the preamble. |
||||
|
exit 1 |
||||
|
;; |
||||
|
|
||||
|
makedepend) |
||||
|
# X makedepend |
||||
|
( |
||||
|
shift |
||||
|
cleared=no |
||||
|
for arg in "$@"; do |
||||
|
case $cleared in no) |
||||
|
set ""; shift |
||||
|
cleared=yes |
||||
|
esac |
||||
|
case "$arg" in |
||||
|
-D*|-I*) |
||||
|
set fnord "$@" "$arg"; shift;; |
||||
|
-*) |
||||
|
;; |
||||
|
*) |
||||
|
set fnord "$@" "$arg"; shift;; |
||||
|
esac |
||||
|
done |
||||
|
obj_suffix="`echo $object | sed 's/^.*\././'`" |
||||
|
touch "$tmpdepfile" |
||||
|
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" |
||||
|
) & |
||||
|
proc=$! |
||||
|
"$@" |
||||
|
stat=$? |
||||
|
wait "$proc" |
||||
|
if test "$stat" != 0; then exit $stat; fi |
||||
|
rm -f "$depfile" |
||||
|
cat < "$tmpdepfile" > "$depfile" |
||||
|
tail +3 "$tmpdepfile" | tr ' ' ' |
||||
|
' | \ |
||||
|
## Some versions of the HPUX 10.20 sed can't process this invocation |
||||
|
## correctly. Breaking it into two sed invocations is a workaround. |
||||
|
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" |
||||
|
rm -f "$tmpdepfile" "$tmpdepfile".bak |
||||
|
;; |
||||
|
|
||||
|
cpp) |
||||
|
# Important note: in order to support this mode, a compiler *must* |
||||
|
# always write the proprocessed file to stdout, regardless of -o, |
||||
|
# because we must use -o when running libtool. |
||||
|
( IFS=" " |
||||
|
case " $* " in |
||||
|
*" --mode=compile "*) |
||||
|
for arg |
||||
|
do # cycle over the arguments |
||||
|
case $arg in |
||||
|
"--mode=compile") |
||||
|
# insert --quiet before "--mode=compile" |
||||
|
set fnord "$@" --quiet |
||||
|
shift # fnord |
||||
|
;; |
||||
|
esac |
||||
|
set fnord "$@" "$arg" |
||||
|
shift # fnord |
||||
|
shift # "$arg" |
||||
|
done |
||||
|
;; |
||||
|
esac |
||||
|
"$@" -E | |
||||
|
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | |
||||
|
sed '$ s: \\$::' > "$tmpdepfile" |
||||
|
) & |
||||
|
proc=$! |
||||
|
"$@" |
||||
|
stat=$? |
||||
|
wait "$proc" |
||||
|
if test "$stat" != 0; then exit $stat; fi |
||||
|
rm -f "$depfile" |
||||
|
echo "$object : \\" > "$depfile" |
||||
|
cat < "$tmpdepfile" >> "$depfile" |
||||
|
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" |
||||
|
rm -f "$tmpdepfile" |
||||
|
;; |
||||
|
|
||||
|
msvisualcpp) |
||||
|
# Important note: in order to support this mode, a compiler *must* |
||||
|
# always write the proprocessed file to stdout, regardless of -o, |
||||
|
# because we must use -o when running libtool. |
||||
|
( IFS=" " |
||||
|
case " $* " in |
||||
|
*" --mode=compile "*) |
||||
|
for arg |
||||
|
do # cycle over the arguments |
||||
|
case $arg in |
||||
|
"--mode=compile") |
||||
|
# insert --quiet before "--mode=compile" |
||||
|
set fnord "$@" --quiet |
||||
|
shift # fnord |
||||
|
;; |
||||
|
esac |
||||
|
set fnord "$@" "$arg" |
||||
|
shift # fnord |
||||
|
shift # "$arg" |
||||
|
done |
||||
|
;; |
||||
|
esac |
||||
|
"$@" -E | |
||||
|
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" |
||||
|
) & |
||||
|
proc=$! |
||||
|
"$@" |
||||
|
stat=$? |
||||
|
wait "$proc" |
||||
|
if test "$stat" != 0; then exit $stat; fi |
||||
|
rm -f "$depfile" |
||||
|
echo "$object : \\" > "$depfile" |
||||
|
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" |
||||
|
echo " " >> "$depfile" |
||||
|
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" |
||||
|
rm -f "$tmpdepfile" |
||||
|
;; |
||||
|
|
||||
|
none) |
||||
|
exec "$@" |
||||
|
;; |
||||
|
|
||||
|
*) |
||||
|
echo "Unknown depmode $depmode" 1>&2 |
||||
|
exit 1 |
||||
|
;; |
||||
|
esac |
||||
|
|
||||
|
exit 0 |
||||
@ -0,0 +1,276 @@ |
|||||
|
#!/bin/sh |
||||
|
# |
||||
|
# install - install a program, script, or datafile |
||||
|
# This comes from X11R5 (mit/util/scripts/install.sh). |
||||
|
# |
||||
|
# Copyright 1991 by the Massachusetts Institute of Technology |
||||
|
# |
||||
|
# Permission to use, copy, modify, distribute, and sell this software and its |
||||
|
# documentation for any purpose is hereby granted without fee, provided that |
||||
|
# the above copyright notice appear in all copies and that both that |
||||
|
# copyright notice and this permission notice appear in supporting |
||||
|
# documentation, and that the name of M.I.T. not be used in advertising or |
||||
|
# publicity pertaining to distribution of the software without specific, |
||||
|
# written prior permission. M.I.T. makes no representations about the |
||||
|
# suitability of this software for any purpose. It is provided "as is" |
||||
|
# without express or implied warranty. |
||||
|
# |
||||
|
# Calling this script install-sh is preferred over install.sh, to prevent |
||||
|
# `make' implicit rules from creating a file called install from it |
||||
|
# when there is no Makefile. |
||||
|
# |
||||
|
# This script is compatible with the BSD install script, but was written |
||||
|
# from scratch. It can only install one file at a time, a restriction |
||||
|
# shared with many OS's install programs. |
||||
|
|
||||
|
|
||||
|
# set DOITPROG to echo to test this script |
||||
|
|
||||
|
# Don't use :- since 4.3BSD and earlier shells don't like it. |
||||
|
doit="${DOITPROG-}" |
||||
|
|
||||
|
|
||||
|
# put in absolute paths if you don't have them in your path; or use env. vars. |
||||
|
|
||||
|
mvprog="${MVPROG-mv}" |
||||
|
cpprog="${CPPROG-cp}" |
||||
|
chmodprog="${CHMODPROG-chmod}" |
||||
|
chownprog="${CHOWNPROG-chown}" |
||||
|
chgrpprog="${CHGRPPROG-chgrp}" |
||||
|
stripprog="${STRIPPROG-strip}" |
||||
|
rmprog="${RMPROG-rm}" |
||||
|
mkdirprog="${MKDIRPROG-mkdir}" |
||||
|
|
||||
|
transformbasename="" |
||||
|
transform_arg="" |
||||
|
instcmd="$mvprog" |
||||
|
chmodcmd="$chmodprog 0755" |
||||
|
chowncmd="" |
||||
|
chgrpcmd="" |
||||
|
stripcmd="" |
||||
|
rmcmd="$rmprog -f" |
||||
|
mvcmd="$mvprog" |
||||
|
src="" |
||||
|
dst="" |
||||
|
dir_arg="" |
||||
|
|
||||
|
while [ x"$1" != x ]; do |
||||
|
case $1 in |
||||
|
-c) instcmd=$cpprog |
||||
|
shift |
||||
|
continue;; |
||||
|
|
||||
|
-d) dir_arg=true |
||||
|
shift |
||||
|
continue;; |
||||
|
|
||||
|
-m) chmodcmd="$chmodprog $2" |
||||
|
shift |
||||
|
shift |
||||
|
continue;; |
||||
|
|
||||
|
-o) chowncmd="$chownprog $2" |
||||
|
shift |
||||
|
shift |
||||
|
continue;; |
||||
|
|
||||
|
-g) chgrpcmd="$chgrpprog $2" |
||||
|
shift |
||||
|
shift |
||||
|
continue;; |
||||
|
|
||||
|
-s) stripcmd=$stripprog |
||||
|
shift |
||||
|
continue;; |
||||
|
|
||||
|
-t=*) transformarg=`echo $1 | sed 's/-t=//'` |
||||
|
shift |
||||
|
continue;; |
||||
|
|
||||
|
-b=*) transformbasename=`echo $1 | sed 's/-b=//'` |
||||
|
shift |
||||
|
continue;; |
||||
|
|
||||
|
*) if [ x"$src" = x ] |
||||
|
then |
||||
|
src=$1 |
||||
|
else |
||||
|
# this colon is to work around a 386BSD /bin/sh bug |
||||
|
: |
||||
|
dst=$1 |
||||
|
fi |
||||
|
shift |
||||
|
continue;; |
||||
|
esac |
||||
|
done |
||||
|
|
||||
|
if [ x"$src" = x ] |
||||
|
then |
||||
|
echo "$0: no input file specified" >&2 |
||||
|
exit 1 |
||||
|
else |
||||
|
: |
||||
|
fi |
||||
|
|
||||
|
if [ x"$dir_arg" != x ]; then |
||||
|
dst=$src |
||||
|
src="" |
||||
|
|
||||
|
if [ -d "$dst" ]; then |
||||
|
instcmd=: |
||||
|
chmodcmd="" |
||||
|
else |
||||
|
instcmd=$mkdirprog |
||||
|
fi |
||||
|
else |
||||
|
|
||||
|
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command |
||||
|
# might cause directories to be created, which would be especially bad |
||||
|
# if $src (and thus $dsttmp) contains '*'. |
||||
|
|
||||
|
if [ -f "$src" ] || [ -d "$src" ] |
||||
|
then |
||||
|
: |
||||
|
else |
||||
|
echo "$0: $src does not exist" >&2 |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
if [ x"$dst" = x ] |
||||
|
then |
||||
|
echo "$0: no destination specified" >&2 |
||||
|
exit 1 |
||||
|
else |
||||
|
: |
||||
|
fi |
||||
|
|
||||
|
# If destination is a directory, append the input filename; if your system |
||||
|
# does not like double slashes in filenames, you may need to add some logic |
||||
|
|
||||
|
if [ -d "$dst" ] |
||||
|
then |
||||
|
dst=$dst/`basename "$src"` |
||||
|
else |
||||
|
: |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
## this sed command emulates the dirname command |
||||
|
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` |
||||
|
|
||||
|
# Make sure that the destination directory exists. |
||||
|
# this part is taken from Noah Friedman's mkinstalldirs script |
||||
|
|
||||
|
# Skip lots of stat calls in the usual case. |
||||
|
if [ ! -d "$dstdir" ]; then |
||||
|
defaultIFS=' |
||||
|
' |
||||
|
IFS="${IFS-$defaultIFS}" |
||||
|
|
||||
|
oIFS=$IFS |
||||
|
# Some sh's can't handle IFS=/ for some reason. |
||||
|
IFS='%' |
||||
|
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` |
||||
|
IFS=$oIFS |
||||
|
|
||||
|
pathcomp='' |
||||
|
|
||||
|
while [ $# -ne 0 ] ; do |
||||
|
pathcomp=$pathcomp$1 |
||||
|
shift |
||||
|
|
||||
|
if [ ! -d "$pathcomp" ] ; |
||||
|
then |
||||
|
$mkdirprog "$pathcomp" |
||||
|
else |
||||
|
: |
||||
|
fi |
||||
|
|
||||
|
pathcomp=$pathcomp/ |
||||
|
done |
||||
|
fi |
||||
|
|
||||
|
if [ x"$dir_arg" != x ] |
||||
|
then |
||||
|
$doit $instcmd "$dst" && |
||||
|
|
||||
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && |
||||
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && |
||||
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && |
||||
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi |
||||
|
else |
||||
|
|
||||
|
# If we're going to rename the final executable, determine the name now. |
||||
|
|
||||
|
if [ x"$transformarg" = x ] |
||||
|
then |
||||
|
dstfile=`basename "$dst"` |
||||
|
else |
||||
|
dstfile=`basename "$dst" $transformbasename | |
||||
|
sed $transformarg`$transformbasename |
||||
|
fi |
||||
|
|
||||
|
# don't allow the sed command to completely eliminate the filename |
||||
|
|
||||
|
if [ x"$dstfile" = x ] |
||||
|
then |
||||
|
dstfile=`basename "$dst"` |
||||
|
else |
||||
|
: |
||||
|
fi |
||||
|
|
||||
|
# Make a couple of temp file names in the proper directory. |
||||
|
|
||||
|
dsttmp=$dstdir/#inst.$$# |
||||
|
rmtmp=$dstdir/#rm.$$# |
||||
|
|
||||
|
# Trap to clean up temp files at exit. |
||||
|
|
||||
|
trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 |
||||
|
trap '(exit $?); exit' 1 2 13 15 |
||||
|
|
||||
|
# Move or copy the file name to the temp name |
||||
|
|
||||
|
$doit $instcmd "$src" "$dsttmp" && |
||||
|
|
||||
|
# and set any options; do chmod last to preserve setuid bits |
||||
|
|
||||
|
# If any of these fail, we abort the whole thing. If we want to |
||||
|
# ignore errors from any of these, just make sure not to ignore |
||||
|
# errors from the above "$doit $instcmd $src $dsttmp" command. |
||||
|
|
||||
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && |
||||
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && |
||||
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && |
||||
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && |
||||
|
|
||||
|
# Now remove or move aside any old file at destination location. We try this |
||||
|
# two ways since rm can't unlink itself on some systems and the destination |
||||
|
# file might be busy for other reasons. In this case, the final cleanup |
||||
|
# might fail but the new file should still install successfully. |
||||
|
|
||||
|
{ |
||||
|
if [ -f "$dstdir/$dstfile" ] |
||||
|
then |
||||
|
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || |
||||
|
$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || |
||||
|
{ |
||||
|
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 |
||||
|
(exit 1); exit |
||||
|
} |
||||
|
else |
||||
|
: |
||||
|
fi |
||||
|
} && |
||||
|
|
||||
|
# Now rename the file to the real destination. |
||||
|
|
||||
|
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile" |
||||
|
|
||||
|
fi && |
||||
|
|
||||
|
# The final little trick to "correctly" pass the exit status to the exit trap. |
||||
|
|
||||
|
{ |
||||
|
(exit 0); exit |
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,336 @@ |
|||||
|
#! /bin/sh |
||||
|
# Common stub for a few missing GNU programs while installing. |
||||
|
# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. |
||||
|
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. |
||||
|
|
||||
|
# This program is free software; you can redistribute it and/or modify |
||||
|
# it under the terms of the GNU General Public License as published by |
||||
|
# the Free Software Foundation; either version 2, or (at your option) |
||||
|
# any later version. |
||||
|
|
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU General Public License for more details. |
||||
|
|
||||
|
# You should have received a copy of the GNU General Public License |
||||
|
# along with this program; if not, write to the Free Software |
||||
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
||||
|
# 02111-1307, USA. |
||||
|
|
||||
|
# As a special exception to the GNU General Public License, if you |
||||
|
# distribute this file as part of a program that contains a |
||||
|
# configuration script generated by Autoconf, you may include it under |
||||
|
# the same distribution terms that you use for the rest of that program. |
||||
|
|
||||
|
if test $# -eq 0; then |
||||
|
echo 1>&2 "Try \`$0 --help' for more information" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
run=: |
||||
|
|
||||
|
# In the cases where this matters, `missing' is being run in the |
||||
|
# srcdir already. |
||||
|
if test -f configure.ac; then |
||||
|
configure_ac=configure.ac |
||||
|
else |
||||
|
configure_ac=configure.in |
||||
|
fi |
||||
|
|
||||
|
case "$1" in |
||||
|
--run) |
||||
|
# Try to run requested program, and just exit if it succeeds. |
||||
|
run= |
||||
|
shift |
||||
|
"$@" && exit 0 |
||||
|
;; |
||||
|
esac |
||||
|
|
||||
|
# If it does not exist, or fails to run (possibly an outdated version), |
||||
|
# try to emulate it. |
||||
|
case "$1" in |
||||
|
|
||||
|
-h|--h|--he|--hel|--help) |
||||
|
echo "\ |
||||
|
$0 [OPTION]... PROGRAM [ARGUMENT]... |
||||
|
|
||||
|
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an |
||||
|
error status if there is no known handling for PROGRAM. |
||||
|
|
||||
|
Options: |
||||
|
-h, --help display this help and exit |
||||
|
-v, --version output version information and exit |
||||
|
--run try to run the given command, and emulate it if it fails |
||||
|
|
||||
|
Supported PROGRAM values: |
||||
|
aclocal touch file \`aclocal.m4' |
||||
|
autoconf touch file \`configure' |
||||
|
autoheader touch file \`config.h.in' |
||||
|
automake touch all \`Makefile.in' files |
||||
|
bison create \`y.tab.[ch]', if possible, from existing .[ch] |
||||
|
flex create \`lex.yy.c', if possible, from existing .c |
||||
|
help2man touch the output file |
||||
|
lex create \`lex.yy.c', if possible, from existing .c |
||||
|
makeinfo touch the output file |
||||
|
tar try tar, gnutar, gtar, then tar without non-portable flags |
||||
|
yacc create \`y.tab.[ch]', if possible, from existing .[ch]" |
||||
|
;; |
||||
|
|
||||
|
-v|--v|--ve|--ver|--vers|--versi|--versio|--version) |
||||
|
echo "missing 0.4 - GNU automake" |
||||
|
;; |
||||
|
|
||||
|
-*) |
||||
|
echo 1>&2 "$0: Unknown \`$1' option" |
||||
|
echo 1>&2 "Try \`$0 --help' for more information" |
||||
|
exit 1 |
||||
|
;; |
||||
|
|
||||
|
aclocal*) |
||||
|
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then |
||||
|
# We have it, but it failed. |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is missing on your system. You should only need it if |
||||
|
you modified \`acinclude.m4' or \`${configure_ac}'. You might want |
||||
|
to install the \`Automake' and \`Perl' packages. Grab them from |
||||
|
any GNU archive site." |
||||
|
touch aclocal.m4 |
||||
|
;; |
||||
|
|
||||
|
autoconf) |
||||
|
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then |
||||
|
# We have it, but it failed. |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is missing on your system. You should only need it if |
||||
|
you modified \`${configure_ac}'. You might want to install the |
||||
|
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU |
||||
|
archive site." |
||||
|
touch configure |
||||
|
;; |
||||
|
|
||||
|
autoheader) |
||||
|
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then |
||||
|
# We have it, but it failed. |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is missing on your system. You should only need it if |
||||
|
you modified \`acconfig.h' or \`${configure_ac}'. You might want |
||||
|
to install the \`Autoconf' and \`GNU m4' packages. Grab them |
||||
|
from any GNU archive site." |
||||
|
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` |
||||
|
test -z "$files" && files="config.h" |
||||
|
touch_files= |
||||
|
for f in $files; do |
||||
|
case "$f" in |
||||
|
*:*) touch_files="$touch_files "`echo "$f" | |
||||
|
sed -e 's/^[^:]*://' -e 's/:.*//'`;; |
||||
|
*) touch_files="$touch_files $f.in";; |
||||
|
esac |
||||
|
done |
||||
|
touch $touch_files |
||||
|
;; |
||||
|
|
||||
|
automake*) |
||||
|
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then |
||||
|
# We have it, but it failed. |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is missing on your system. You should only need it if |
||||
|
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. |
||||
|
You might want to install the \`Automake' and \`Perl' packages. |
||||
|
Grab them from any GNU archive site." |
||||
|
find . -type f -name Makefile.am -print | |
||||
|
sed 's/\.am$/.in/' | |
||||
|
while read f; do touch "$f"; done |
||||
|
;; |
||||
|
|
||||
|
autom4te) |
||||
|
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then |
||||
|
# We have it, but it failed. |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is needed, and you do not seem to have it handy on your |
||||
|
system. You might have modified some files without having the |
||||
|
proper tools for further handling them. |
||||
|
You can get \`$1Help2man' as part of \`Autoconf' from any GNU |
||||
|
archive site." |
||||
|
|
||||
|
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` |
||||
|
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` |
||||
|
if test -f "$file"; then |
||||
|
touch $file |
||||
|
else |
||||
|
test -z "$file" || exec >$file |
||||
|
echo "#! /bin/sh" |
||||
|
echo "# Created by GNU Automake missing as a replacement of" |
||||
|
echo "# $ $@" |
||||
|
echo "exit 0" |
||||
|
chmod +x $file |
||||
|
exit 1 |
||||
|
fi |
||||
|
;; |
||||
|
|
||||
|
bison|yacc) |
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is missing on your system. You should only need it if |
||||
|
you modified a \`.y' file. You may need the \`Bison' package |
||||
|
in order for those modifications to take effect. You can get |
||||
|
\`Bison' from any GNU archive site." |
||||
|
rm -f y.tab.c y.tab.h |
||||
|
if [ $# -ne 1 ]; then |
||||
|
eval LASTARG="\${$#}" |
||||
|
case "$LASTARG" in |
||||
|
*.y) |
||||
|
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` |
||||
|
if [ -f "$SRCFILE" ]; then |
||||
|
cp "$SRCFILE" y.tab.c |
||||
|
fi |
||||
|
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` |
||||
|
if [ -f "$SRCFILE" ]; then |
||||
|
cp "$SRCFILE" y.tab.h |
||||
|
fi |
||||
|
;; |
||||
|
esac |
||||
|
fi |
||||
|
if [ ! -f y.tab.h ]; then |
||||
|
echo >y.tab.h |
||||
|
fi |
||||
|
if [ ! -f y.tab.c ]; then |
||||
|
echo 'main() { return 0; }' >y.tab.c |
||||
|
fi |
||||
|
;; |
||||
|
|
||||
|
lex|flex) |
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is missing on your system. You should only need it if |
||||
|
you modified a \`.l' file. You may need the \`Flex' package |
||||
|
in order for those modifications to take effect. You can get |
||||
|
\`Flex' from any GNU archive site." |
||||
|
rm -f lex.yy.c |
||||
|
if [ $# -ne 1 ]; then |
||||
|
eval LASTARG="\${$#}" |
||||
|
case "$LASTARG" in |
||||
|
*.l) |
||||
|
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` |
||||
|
if [ -f "$SRCFILE" ]; then |
||||
|
cp "$SRCFILE" lex.yy.c |
||||
|
fi |
||||
|
;; |
||||
|
esac |
||||
|
fi |
||||
|
if [ ! -f lex.yy.c ]; then |
||||
|
echo 'main() { return 0; }' >lex.yy.c |
||||
|
fi |
||||
|
;; |
||||
|
|
||||
|
help2man) |
||||
|
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then |
||||
|
# We have it, but it failed. |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is missing on your system. You should only need it if |
||||
|
you modified a dependency of a manual page. You may need the |
||||
|
\`Help2man' package in order for those modifications to take |
||||
|
effect. You can get \`Help2man' from any GNU archive site." |
||||
|
|
||||
|
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` |
||||
|
if test -z "$file"; then |
||||
|
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` |
||||
|
fi |
||||
|
if [ -f "$file" ]; then |
||||
|
touch $file |
||||
|
else |
||||
|
test -z "$file" || exec >$file |
||||
|
echo ".ab help2man is required to generate this page" |
||||
|
exit 1 |
||||
|
fi |
||||
|
;; |
||||
|
|
||||
|
makeinfo) |
||||
|
if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then |
||||
|
# We have makeinfo, but it failed. |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is missing on your system. You should only need it if |
||||
|
you modified a \`.texi' or \`.texinfo' file, or any other file |
||||
|
indirectly affecting the aspect of the manual. The spurious |
||||
|
call might also be the consequence of using a buggy \`make' (AIX, |
||||
|
DU, IRIX). You might want to install the \`Texinfo' package or |
||||
|
the \`GNU make' package. Grab either from any GNU archive site." |
||||
|
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` |
||||
|
if test -z "$file"; then |
||||
|
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` |
||||
|
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` |
||||
|
fi |
||||
|
touch $file |
||||
|
;; |
||||
|
|
||||
|
tar) |
||||
|
shift |
||||
|
if test -n "$run"; then |
||||
|
echo 1>&2 "ERROR: \`tar' requires --run" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# We have already tried tar in the generic part. |
||||
|
# Look for gnutar/gtar before invocation to avoid ugly error |
||||
|
# messages. |
||||
|
if (gnutar --version > /dev/null 2>&1); then |
||||
|
gnutar "$@" && exit 0 |
||||
|
fi |
||||
|
if (gtar --version > /dev/null 2>&1); then |
||||
|
gtar "$@" && exit 0 |
||||
|
fi |
||||
|
firstarg="$1" |
||||
|
if shift; then |
||||
|
case "$firstarg" in |
||||
|
*o*) |
||||
|
firstarg=`echo "$firstarg" | sed s/o//` |
||||
|
tar "$firstarg" "$@" && exit 0 |
||||
|
;; |
||||
|
esac |
||||
|
case "$firstarg" in |
||||
|
*h*) |
||||
|
firstarg=`echo "$firstarg" | sed s/h//` |
||||
|
tar "$firstarg" "$@" && exit 0 |
||||
|
;; |
||||
|
esac |
||||
|
fi |
||||
|
|
||||
|
echo 1>&2 "\ |
||||
|
WARNING: I can't seem to be able to run \`tar' with the given arguments. |
||||
|
You may want to install GNU tar or Free paxutils, or check the |
||||
|
command line arguments." |
||||
|
exit 1 |
||||
|
;; |
||||
|
|
||||
|
*) |
||||
|
echo 1>&2 "\ |
||||
|
WARNING: \`$1' is needed, and you do not seem to have it handy on your |
||||
|
system. You might have modified some files without having the |
||||
|
proper tools for further handling them. Check the \`README' file, |
||||
|
it often tells you about the needed prerequirements for installing |
||||
|
this package. You may also peek at any GNU archive site, in case |
||||
|
some other package would contain this missing \`$1' program." |
||||
|
exit 1 |
||||
|
;; |
||||
|
esac |
||||
|
|
||||
|
exit 0 |
||||
@ -0,0 +1,111 @@ |
|||||
|
#! /bin/sh |
||||
|
# mkinstalldirs --- make directory hierarchy |
||||
|
# Author: Noah Friedman <friedman@prep.ai.mit.edu> |
||||
|
# Created: 1993-05-16 |
||||
|
# Public domain |
||||
|
|
||||
|
errstatus=0 |
||||
|
dirmode="" |
||||
|
|
||||
|
usage="\ |
||||
|
Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." |
||||
|
|
||||
|
# process command line arguments |
||||
|
while test $# -gt 0 ; do |
||||
|
case $1 in |
||||
|
-h | --help | --h*) # -h for help |
||||
|
echo "$usage" 1>&2 |
||||
|
exit 0 |
||||
|
;; |
||||
|
-m) # -m PERM arg |
||||
|
shift |
||||
|
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } |
||||
|
dirmode=$1 |
||||
|
shift |
||||
|
;; |
||||
|
--) # stop option processing |
||||
|
shift |
||||
|
break |
||||
|
;; |
||||
|
-*) # unknown option |
||||
|
echo "$usage" 1>&2 |
||||
|
exit 1 |
||||
|
;; |
||||
|
*) # first non-opt arg |
||||
|
break |
||||
|
;; |
||||
|
esac |
||||
|
done |
||||
|
|
||||
|
for file |
||||
|
do |
||||
|
if test -d "$file"; then |
||||
|
shift |
||||
|
else |
||||
|
break |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
case $# in |
||||
|
0) exit 0 ;; |
||||
|
esac |
||||
|
|
||||
|
case $dirmode in |
||||
|
'') |
||||
|
if mkdir -p -- . 2>/dev/null; then |
||||
|
echo "mkdir -p -- $*" |
||||
|
exec mkdir -p -- "$@" |
||||
|
fi |
||||
|
;; |
||||
|
*) |
||||
|
if mkdir -m "$dirmode" -p -- . 2>/dev/null; then |
||||
|
echo "mkdir -m $dirmode -p -- $*" |
||||
|
exec mkdir -m "$dirmode" -p -- "$@" |
||||
|
fi |
||||
|
;; |
||||
|
esac |
||||
|
|
||||
|
for file |
||||
|
do |
||||
|
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` |
||||
|
shift |
||||
|
|
||||
|
pathcomp= |
||||
|
for d |
||||
|
do |
||||
|
pathcomp="$pathcomp$d" |
||||
|
case $pathcomp in |
||||
|
-*) pathcomp=./$pathcomp ;; |
||||
|
esac |
||||
|
|
||||
|
if test ! -d "$pathcomp"; then |
||||
|
echo "mkdir $pathcomp" |
||||
|
|
||||
|
mkdir "$pathcomp" || lasterr=$? |
||||
|
|
||||
|
if test ! -d "$pathcomp"; then |
||||
|
errstatus=$lasterr |
||||
|
else |
||||
|
if test ! -z "$dirmode"; then |
||||
|
echo "chmod $dirmode $pathcomp" |
||||
|
lasterr="" |
||||
|
chmod "$dirmode" "$pathcomp" || lasterr=$? |
||||
|
|
||||
|
if test ! -z "$lasterr"; then |
||||
|
errstatus=$lasterr |
||||
|
fi |
||||
|
fi |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
pathcomp="$pathcomp/" |
||||
|
done |
||||
|
done |
||||
|
|
||||
|
exit $errstatus |
||||
|
|
||||
|
# Local Variables: |
||||
|
# mode: shell-script |
||||
|
# sh-indentation: 2 |
||||
|
# End: |
||||
|
# mkinstalldirs ends here |
||||
@ -0,0 +1,124 @@ |
|||||
|
/**
|
||||
|
* #(@)nomfichier.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Implantation de la classe Banque. |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
/*
|
||||
|
* @Fait tout |
||||
|
* |
||||
|
* @Afaire - |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
|
#include "Banque.h" |
||||
|
|
||||
|
#include <cstdlib> |
||||
|
#include <sstream> |
||||
|
#include "CompteCheque.h" |
||||
|
#include "Livret.h" |
||||
|
#include "PlanEpargneLogement.h" |
||||
|
|
||||
|
Banque::Banque() { |
||||
|
this->_nbCompte = TAILLE_BANQUE; |
||||
|
|
||||
|
for (int i = 0; i < _nbCompte; i++) { |
||||
|
std::ostringstream oss; |
||||
|
oss << i; |
||||
|
this->_comptes[i] = this->creerNouveauCompte(oss.str()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Banque::~Banque() { |
||||
|
int nbCompte = this->nbCompte(); |
||||
|
|
||||
|
for (int i = 0; i < nbCompte; i++) { |
||||
|
delete _comptes[i]; |
||||
|
_comptes[i] = 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
int Banque::nbCompte() const { |
||||
|
return this->_nbCompte; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Compte * Banque::creerNouveauCompte(std::string nom) const { |
||||
|
int type = random(4); |
||||
|
double solde = random(500) * 10.0; |
||||
|
Compte * cpt = 0; |
||||
|
|
||||
|
switch(type) { |
||||
|
case 0: |
||||
|
cpt = new Compte(nom, solde); |
||||
|
break; |
||||
|
case 1: |
||||
|
cpt = new CompteCheque(nom, -500, solde); |
||||
|
break; |
||||
|
case 2: |
||||
|
cpt = new Livret(nom, 0.1, solde); |
||||
|
break; |
||||
|
default: |
||||
|
cpt = new PlanEpargneLogement(nom, 0.1, solde); |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
return cpt; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
int random(int randMax) { |
||||
|
return (int) (((double)randMax) * (rand() / (RAND_MAX + 1.0))); |
||||
|
} |
||||
|
|
||||
|
Compte * const * Banque::comptes() const { |
||||
|
return this->_comptes; |
||||
|
} |
||||
|
|
||||
|
double Banque::calculeSommeSolde() const { |
||||
|
double somme = 0; |
||||
|
Compte * const * comptes = this->comptes(); |
||||
|
for (int i = this->nbCompte() - 1; i >= 0; i--) { |
||||
|
somme += comptes[i]->solde(); |
||||
|
} |
||||
|
|
||||
|
return somme; |
||||
|
} |
||||
|
|
||||
|
bool Banque::effectueVirements( int nbVirement ) const { |
||||
|
Compte * const * comptes = this->comptes(); |
||||
|
int nbCompte = this->nbCompte(); |
||||
|
double soldeInitial = this->calculeSommeSolde(); |
||||
|
|
||||
|
for (int i = nbVirement -1; i >= 0; i--) { |
||||
|
Compte * src = comptes[random(nbCompte)]; |
||||
|
Compte * dest = 0; |
||||
|
double montant = random(500) * 10; |
||||
|
|
||||
|
do { |
||||
|
dest = comptes[random(nbCompte)]; |
||||
|
} while (src == dest); |
||||
|
|
||||
|
src->virement(dest, montant); |
||||
|
} |
||||
|
|
||||
|
return soldeInitial == this->calculeSommeSolde(); |
||||
|
} |
||||
|
|
||||
|
|
||||
@ -0,0 +1,109 @@ |
|||||
|
/**
|
||||
|
* #(@)nomfichier.h ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
#ifndef BANQUE_H |
||||
|
#define BANQUE_H |
||||
|
|
||||
|
#include "Compte.h" |
||||
|
|
||||
|
/* Nombre de comptes dans une banque */ |
||||
|
#define TAILLE_BANQUE 10 |
||||
|
|
||||
|
/**
|
||||
|
* Définition de la classe Banque. Une banque est un regroupement de comptes. |
||||
|
* |
||||
|
* @author Nicolas MASSE |
||||
|
* @author Thomas LIMIN |
||||
|
*/ |
||||
|
class Banque { |
||||
|
|
||||
|
public: |
||||
|
|
||||
|
/**
|
||||
|
* Constructeur de Banque |
||||
|
*/ |
||||
|
Banque(); |
||||
|
|
||||
|
/**
|
||||
|
* Destructeur de Banque |
||||
|
*/ |
||||
|
~Banque(); |
||||
|
|
||||
|
/**
|
||||
|
* Calcule la somme des soldes des comptes |
||||
|
* |
||||
|
* @return la somme des solde des comptes |
||||
|
*/ |
||||
|
double calculeSommeSolde() const; |
||||
|
|
||||
|
/**
|
||||
|
* Effectue le nombre voulue d'opération de virement, |
||||
|
* les comptes sources, destination et le montant étant |
||||
|
* choisis aléatoirement |
||||
|
* |
||||
|
* @param nbVirement le nombre de virement à effectuer (>=0) |
||||
|
* @return true si le solde total reste constant, false sinon |
||||
|
*/ |
||||
|
bool effectueVirements(int nbVirement) const; |
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le nombre de compte gérés |
||||
|
* |
||||
|
* @return le nb de comptes |
||||
|
*/ |
||||
|
int nbCompte() const; |
||||
|
|
||||
|
/**
|
||||
|
* Cree un nouveau compte. Le type précis de l'objet retourné |
||||
|
* est choisi aléatoirement dans {Compte, CompteCheque, Livret, |
||||
|
* PlanEpargneLogement} |
||||
|
* |
||||
|
* @param nom le nom du compte à créer |
||||
|
* @return un nouveau compte |
||||
|
*/ |
||||
|
Compte * creerNouveauCompte(std::string nom) const; |
||||
|
|
||||
|
/**
|
||||
|
* Retoune le tableau de comptes |
||||
|
* |
||||
|
* @return _comptes |
||||
|
*/ |
||||
|
Compte * const * comptes() const; |
||||
|
|
||||
|
/**
|
||||
|
* Le tableau de comptes gérés par cette banque |
||||
|
*/ |
||||
|
Compte * _comptes[TAILLE_BANQUE]; |
||||
|
|
||||
|
/**
|
||||
|
* Le nombre de comptes gérés par la banque |
||||
|
*/ |
||||
|
int _nbCompte; |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
/**
|
||||
|
* Tire un nombre aléatoire compris dans [ 0, randMax [ |
||||
|
* |
||||
|
* @param randMax la limite supérieure (exclue) |
||||
|
* @return un nombre aléatoire; |
||||
|
*/ |
||||
|
int random(int randMax); |
||||
|
|
||||
|
|
||||
|
#endif /* BANQUE_H */ |
||||
@ -0,0 +1,174 @@ |
|||||
|
/**
|
||||
|
* #(@)Compte.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Implémentation de la classe Compte. |
||||
|
*/ |
||||
|
|
||||
|
#include "Compte.h" |
||||
|
#include <sstream> |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
/* Variable de classe, voir Compte.h */ |
||||
|
long Compte::_prochainNumeroDeCompte = 1; |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Définition des constructeurs/destructeur |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
Compte::Compte(string nom, double solde) { |
||||
|
this->setNomProprietaire(nom); |
||||
|
this->setSolde(solde); |
||||
|
this->setNumeroDeCompte(Compte::prochainNumeroDeCompte()); |
||||
|
cout << *this << ": Compte::Compte(\"" << nom << "\")" << endl; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Compte::~Compte() { |
||||
|
cout << *this << ": Compte::~Compte()" << endl; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Définition des accesseurs |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
string Compte::nomProprietaire() const { |
||||
|
return _nomProprietaire; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void Compte::setNomProprietaire(string theValue) { |
||||
|
_nomProprietaire = theValue; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
long Compte::numeroDeCompte() const { |
||||
|
return _numeroDeCompte; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void Compte::setNumeroDeCompte(long theValue) { |
||||
|
_numeroDeCompte = theValue; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
double Compte::solde() const { |
||||
|
return _solde; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void Compte::setSolde(double theValue) { |
||||
|
_solde = theValue; |
||||
|
} |
||||
|
|
||||
|
long Compte::prochainNumeroDeCompte() { |
||||
|
return Compte::_prochainNumeroDeCompte++; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Méthodes utilitaires. |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
string Compte::toString() const { |
||||
|
ostringstream oss; |
||||
|
|
||||
|
oss << "Compte(numeroCompte = "; |
||||
|
oss << this->numeroDeCompte(); |
||||
|
oss << ", nomProprietaire = "; |
||||
|
oss << this->nomProprietaire(); |
||||
|
oss << ", solde = "; |
||||
|
oss << this->solde(); |
||||
|
oss << ")"; |
||||
|
return oss.str(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Fonctions |
||||
|
* |
||||
|
*/ |
||||
|
std::ostream & operator<<(std::ostream & st, const Compte & cpt) { |
||||
|
st << cpt.toString(); |
||||
|
return st; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Opérations bancaires. |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
bool Compte::depose(double montant) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if (montant < 0) { |
||||
|
std::cerr << *this << ": Compte::depose(" << montant << "): ne peut deposer un montant négatif." << std::endl; |
||||
|
} else { |
||||
|
cout << *this << ": Compte::depose(" << montant << ")" << endl; |
||||
|
this->setSolde(this->solde() + montant); |
||||
|
result = true; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool Compte::retrait(double montant) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if (montant < 0) { |
||||
|
std::cerr << *this << ": Compte::retrait(" << montant << "): ne peut retirer un montant négatif." << std::endl; |
||||
|
} else { |
||||
|
std::cout << *this << ": Compte::retrait(" << montant << ")" << std::endl; |
||||
|
this->setSolde(this->solde() - montant); |
||||
|
result = true; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
bool Compte::virement( Compte * compteDest, double montant ) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if (this->retrait(montant)) { |
||||
|
if (compteDest->depose(montant)) { |
||||
|
std::cout << "Virement réussi: " << montant << " " << *this << " => " << *compteDest << std::endl; |
||||
|
result = true; |
||||
|
} else { |
||||
|
this->depose(montant); |
||||
|
std::cerr << "Erreur lors du virement: depot refusé " << montant << " " << *this << " => " << *compteDest << std::endl; |
||||
|
} |
||||
|
} else { |
||||
|
std::cerr << "Erreur lors du virement: retrait refusé " << montant << " " << *this << " => " << *compteDest << std::endl; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
@ -0,0 +1,162 @@ |
|||||
|
/**
|
||||
|
* #(@)Compte.h ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* TP Compte bancaire |
||||
|
*/ |
||||
|
|
||||
|
#ifndef COMPTE_H |
||||
|
#define COMPTE_H |
||||
|
|
||||
|
#include <string> |
||||
|
#include <iostream> |
||||
|
|
||||
|
/**
|
||||
|
* Représente un compte bancaire générique. |
||||
|
*/ |
||||
|
class Compte { |
||||
|
public: |
||||
|
/*
|
||||
|
* |
||||
|
* Constructeurs/destructeur |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Construit un compte. |
||||
|
*/ |
||||
|
Compte(std::string nom, double solde = 0); |
||||
|
|
||||
|
/**
|
||||
|
* Détruit un compte. |
||||
|
*/ |
||||
|
virtual ~Compte(); |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le nom du propriétaire de ce compte. |
||||
|
*/ |
||||
|
std::string nomProprietaire() const; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Retourne le numéro de ce compte. |
||||
|
*/ |
||||
|
long numeroDeCompte() const; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Retourne le solde de ce compte. |
||||
|
*/ |
||||
|
double solde() const; |
||||
|
|
||||
|
/**
|
||||
|
* Retourne un numéro de compte unique. |
||||
|
*/ |
||||
|
static long prochainNumeroDeCompte(); |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Méthodes utilitaires. |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Retourne une représentation textuelle de ce compte. |
||||
|
*/ |
||||
|
virtual std::string toString() const; |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Opérations bancaires |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Dépose un montant (nécessairement positif) sur ce compte |
||||
|
* |
||||
|
* @param montant le montant à déposer. |
||||
|
* @return true si l'opération s'est bien passée |
||||
|
*/ |
||||
|
virtual bool depose(double montant); |
||||
|
|
||||
|
/**
|
||||
|
* Retire un montant (nécessairement positif) sur ce compte. |
||||
|
* |
||||
|
* @param montant le montant à retirer. |
||||
|
* @return true si l'opération s'est bien passée |
||||
|
*/ |
||||
|
virtual bool retrait(double montant); |
||||
|
|
||||
|
/**
|
||||
|
* Effectue un virement. Le montant est transféré depuis |
||||
|
* l'objet compte courant vers l'objet compte fournis en |
||||
|
* paramètre. |
||||
|
* |
||||
|
* @param compteDest la destination du montant viré |
||||
|
* @param montant le montant viré |
||||
|
*/ |
||||
|
bool virement(Compte * compteDest, double montant); |
||||
|
|
||||
|
private: |
||||
|
/**
|
||||
|
* Definit le solde de ce compte. |
||||
|
*/ |
||||
|
void setSolde(double theValue); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Definit le nom du propriétaire de ce compte. |
||||
|
*/ |
||||
|
void setNomProprietaire(std::string theValue); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Définit le numéro de compte de ce compte. |
||||
|
*/ |
||||
|
void setNumeroDeCompte(long theValue); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Le nom du propriétaire, ne peut pas être null. |
||||
|
*/ |
||||
|
std::string _nomProprietaire; |
||||
|
|
||||
|
/**
|
||||
|
* Le numéro du compte. |
||||
|
*/ |
||||
|
long _numeroDeCompte; |
||||
|
|
||||
|
/**
|
||||
|
* Le solde du compte, peut être négatif. |
||||
|
*/ |
||||
|
double _solde; |
||||
|
|
||||
|
/**
|
||||
|
* Le prochain numéro de compte. |
||||
|
*/ |
||||
|
static long _prochainNumeroDeCompte; |
||||
|
}; |
||||
|
|
||||
|
/**
|
||||
|
* Affiche un compte bancaire sur un flux de sortie |
||||
|
*/ |
||||
|
std::ostream & operator<<(std::ostream & st, const Compte & cpt); |
||||
|
|
||||
|
#endif /* COMPTE_H */ |
||||
@ -0,0 +1,83 @@ |
|||||
|
/**
|
||||
|
* #(@)CompteCheque.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* @Fait tout |
||||
|
* |
||||
|
* @Afaire - |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
|
#include "CompteCheque.h" |
||||
|
#include <sstream> |
||||
|
|
||||
|
CompteCheque::CompteCheque(std::string nom, double decouvertAutorise, double solde) : Compte(nom, solde) { |
||||
|
if ( ! this->setDecouvertAutorise(decouvertAutorise)) { |
||||
|
this->setDecouvertAutorise(0); |
||||
|
} |
||||
|
std::cout << *this << ": CompteCheque::CompteCheque(\"" << nom << "\")" << std::endl; |
||||
|
} |
||||
|
|
||||
|
CompteCheque::~CompteCheque() { |
||||
|
std::cout << *this << ": CompteCheque::~CompteCheque()" << std::endl; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool CompteCheque::retrait(double montant) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if ((this->solde() - montant) >= - this->decouvertAutorise()) { |
||||
|
Compte::retrait(montant); |
||||
|
result = true; |
||||
|
} else { |
||||
|
std::cerr << *this << ": CompteCheque::retrait(" << montant << ") : erreur, le compte chèque n'est pas suffisamment approvisionné" << std::endl; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
double CompteCheque::decouvertAutorise() const { |
||||
|
return _decouvertAutorise; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool CompteCheque::setDecouvertAutorise(double decouvert) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if (decouvert >= 0) { |
||||
|
_decouvertAutorise = decouvert; |
||||
|
result = true; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
std::string CompteCheque::toString( ) const { |
||||
|
std::ostringstream oss; |
||||
|
|
||||
|
oss << "CompteCheque(numeroCompte = "; |
||||
|
oss << this->numeroDeCompte(); |
||||
|
oss << ", nomProprietaire = "; |
||||
|
oss << this->nomProprietaire(); |
||||
|
oss << ", découvertAutorisé = "; |
||||
|
oss << this->decouvertAutorise(); |
||||
|
oss << ", solde = "; |
||||
|
oss << this->solde(); |
||||
|
oss << ")"; |
||||
|
|
||||
|
return oss.str(); |
||||
|
} |
||||
@ -0,0 +1,90 @@ |
|||||
|
/**
|
||||
|
* #(@)nomfichier.h ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
#ifndef COMPTECHEQUE_H |
||||
|
#define COMPTECHEQUE_H |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
#include <Compte.h> |
||||
|
|
||||
|
/**
|
||||
|
* Un compte chèque est un compte pour lequel il existe un montant maximum de |
||||
|
* découvertautorisé. Outre cette donnée, on pourra donc ajouter une méthode pemettant |
||||
|
* d'obtenir ou de modifier ce montant. L'opération de retrait devra tenir compte de |
||||
|
* cette nouvelle donnée. |
||||
|
* |
||||
|
* @author Nicolas MASSE |
||||
|
* @author Thomas LIMIN |
||||
|
*/ |
||||
|
class CompteCheque : public Compte { |
||||
|
|
||||
|
public: |
||||
|
/**
|
||||
|
* Constructeur de compte cheque |
||||
|
* |
||||
|
* @param nom le nom du titulaire du comte |
||||
|
* @param decouvertAutorisé le montant de découvert autorisé (0 par défaut) |
||||
|
* @param solde le solde du compte (0 par défaut) |
||||
|
*/ |
||||
|
CompteCheque(std::string nom, double decouvertAutorise = 0, double solde = 0); |
||||
|
|
||||
|
/**
|
||||
|
* Destructeur |
||||
|
*/ |
||||
|
~CompteCheque(); |
||||
|
|
||||
|
/**
|
||||
|
* Effectue un retrait si et seulement si le solde après retrait est supérieur |
||||
|
* ou égal au montant de découvert autorisé |
||||
|
* |
||||
|
* @param montant le montant du retrait |
||||
|
**/ |
||||
|
bool retrait(double montant); |
||||
|
|
||||
|
/**
|
||||
|
* Renseigne le montant de découvert autorisé. Le montant doit être |
||||
|
* supérieur ou égal à 0, sans quoi le montant reste inchangé et false |
||||
|
* est retourné. |
||||
|
* |
||||
|
* @param decouvert le montant de découvert autorisé |
||||
|
* @return true si le montant est correctement modifié |
||||
|
*/ |
||||
|
bool setDecouvertAutorise(double decouvert); |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le montant de découvert autorisé |
||||
|
* |
||||
|
* @return decouvert autorisé |
||||
|
*/ |
||||
|
double decouvertAutorise() const; |
||||
|
|
||||
|
/**
|
||||
|
* Retourne une représentation textuelle de ce compte. |
||||
|
*/ |
||||
|
std::string toString() const; |
||||
|
|
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/**
|
||||
|
* Le montant de découvert autorisé. Par exemple, la valeur |
||||
|
* 200 indique que le solde minimum du compte est -200 (inclus) |
||||
|
*/ |
||||
|
double _decouvertAutorise; |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,109 @@ |
|||||
|
/**
|
||||
|
* #(@)nomfichier.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Implémentation de la classe Livret. |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
#include "Livret.h" |
||||
|
#include <sstream> |
||||
|
|
||||
|
Livret::Livret(std::string nom, double taux, double solde): Compte(nom, solde) { |
||||
|
if ( ! this->setTaux(taux)) { |
||||
|
this->setTaux(0); |
||||
|
} |
||||
|
this->setSoldeMini(this->solde()); |
||||
|
std::cout << *this << ": Livret::Livret(\"" << nom << "\", taux: " << taux << ", solde: " << solde << ")" << std::endl; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Livret::~ Livret() { |
||||
|
std::cout << *this << ": Livret::~Livret()" << std::endl; |
||||
|
} |
||||
|
|
||||
|
double Livret::taux() const { |
||||
|
return _taux; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool Livret::setTaux(double taux) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if (taux >= 0) { |
||||
|
_taux = taux; |
||||
|
result = true; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
double Livret::soldeMini() const { |
||||
|
return _soldeMini; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool Livret::setSoldeMini(double solde) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if (solde >= 0) { |
||||
|
_soldeMini = solde; |
||||
|
result = true; |
||||
|
} else { |
||||
|
std::cerr << *this << ": Retrait::setSoldeMini(" << solde << ") : erreur, le solde mini ne devrait pas être négatif" << std::endl; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
bool Livret::retrait( double montant ) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if ((this->solde() - montant) >= 0) { |
||||
|
result = Compte::retrait(montant); |
||||
|
if (result && (this->solde() < this->soldeMini())) { |
||||
|
this->setSoldeMini(this->solde()); |
||||
|
} |
||||
|
} else { |
||||
|
std::cerr << *this << ": Livret::retrait(" << montant << ") : erreur, le livret n'est pas suffisamment approvisionné" << std::endl; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
std::string Livret::toString( ) const { |
||||
|
std::ostringstream oss; |
||||
|
|
||||
|
oss << "Livret(numeroCompte = "; |
||||
|
oss << this->numeroDeCompte(); |
||||
|
oss << ", nomProprietaire = "; |
||||
|
oss << this->nomProprietaire(); |
||||
|
oss << ", solde = "; |
||||
|
oss << this->solde(); |
||||
|
oss << ", taux = "; |
||||
|
oss << this->taux(); |
||||
|
oss << ")"; |
||||
|
|
||||
|
return oss.str(); |
||||
|
} |
||||
|
|
||||
|
double Livret::priseDInterets() { |
||||
|
double interet = this->soldeMini() * this->taux(); |
||||
|
std::cout << *this << " : Livret::priseDInterets() => " << interet << std::endl; |
||||
|
this->depose(interet); |
||||
|
this->setSoldeMini(this->solde()); |
||||
|
return interet; |
||||
|
} |
||||
@ -0,0 +1,128 @@ |
|||||
|
/**
|
||||
|
* #(@)nomfichier.h ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
/*
|
||||
|
* @Fait tout |
||||
|
* |
||||
|
* @Afaire - |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
|
#ifndef LIVRET_H |
||||
|
#define LIVRET_H |
||||
|
|
||||
|
#include "Compte.h" |
||||
|
|
||||
|
/**
|
||||
|
* Un livret est un compte dont le solde ne peut être négatif. Il est rémunéré |
||||
|
* sur la base d'un taux d'intérêts spécifié à l'ouverture que l'on suppose fixe |
||||
|
* |
||||
|
* @author Thomas LIMIN |
||||
|
* @author Nicolas MASSE |
||||
|
*/ |
||||
|
class Livret : public Compte { |
||||
|
public: |
||||
|
|
||||
|
/**
|
||||
|
* Constructeur de livret. |
||||
|
* |
||||
|
* @param nom le nom du titulaire du compte |
||||
|
* @param taux le taux d'intêret |
||||
|
* @param solde le solde initial du compte |
||||
|
*/ |
||||
|
Livret(std::string nom, double taux = 0, double solde = 0); |
||||
|
|
||||
|
/**
|
||||
|
* Destructeur |
||||
|
*/ |
||||
|
~Livret(); |
||||
|
|
||||
|
/**
|
||||
|
* Retrait. Sur un livret, il est impossible d'avoir un solde négatif. |
||||
|
* La méthode de retrait prend en compte cette restriction et interdit |
||||
|
* les retrait qui mettraient dans cette situation. |
||||
|
* |
||||
|
* @param montant le montant du retrait |
||||
|
* @return true si le retrait a bien été effectué |
||||
|
*/ |
||||
|
bool retrait(double montant); |
||||
|
|
||||
|
/**
|
||||
|
* Calcule les interêts perçus sur ce compte. |
||||
|
* Cette valeur correspond à la somme mini présente |
||||
|
* sur le compte depuis la dernière prise d'interêts |
||||
|
* par le taux d'interêt. Le montant perçu est immédiatement |
||||
|
* ajouté au compte. |
||||
|
* |
||||
|
* @return le montant des interêts perçus |
||||
|
*/ |
||||
|
double priseDInterets(); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Met à jour le taux d'interêt. Doit être >= 0 |
||||
|
* |
||||
|
* @param taux le nouveaux taux d'interêt |
||||
|
* @return true si modification réussie |
||||
|
*/ |
||||
|
bool setTaux(double taux); |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le taux d'interêt associé à ce livret |
||||
|
* |
||||
|
* @return le taux d'interêt |
||||
|
*/ |
||||
|
virtual double taux() const; |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le taux d'interêt associé à ce livret |
||||
|
* |
||||
|
* @return le solde minimum |
||||
|
*/ |
||||
|
double soldeMini() const; |
||||
|
|
||||
|
/**
|
||||
|
* Retourne une représentation textuelle de ce Livret. |
||||
|
*/ |
||||
|
std::string toString() const; |
||||
|
|
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/**
|
||||
|
* Met à jour le sole minimum. Doit être >= 0 |
||||
|
* |
||||
|
* @param solde le nouveaux solde minimum |
||||
|
* @return true si modification réussie |
||||
|
*/ |
||||
|
bool setSoldeMini(double solde); |
||||
|
|
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Le taux d'interêt appliqué à ce livret |
||||
|
*/ |
||||
|
double _taux; |
||||
|
|
||||
|
/**
|
||||
|
* Le solde mnimum de ce compte depuis la dernière prise d'interêts |
||||
|
*/ |
||||
|
double _soldeMini; |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,11 @@ |
|||||
|
bin_PROGRAMS = tp4_comptesbancaires |
||||
|
tp4_comptesbancaires_SOURCES = tp4_comptesbancaires.cpp Compte.cpp \
|
||||
|
CompteCheque.cpp Livret.cpp PlanEpargneLogement.cpp Moneo.cpp Banque.cpp |
||||
|
|
||||
|
# set the include path found by configure
|
||||
|
INCLUDES= $(all_includes) |
||||
|
|
||||
|
# the library search path.
|
||||
|
tp4_comptesbancaires_LDFLAGS = $(all_libraries) |
||||
|
noinst_HEADERS = Compte.h CompteCheque.h Livret.h PlanEpargneLogement.h \
|
||||
|
Banque.h |
||||
@ -0,0 +1,464 @@ |
|||||
|
# Makefile.in generated by automake 1.9.6 from Makefile.am.
|
||||
|
# @configure_input@
|
||||
|
|
||||
|
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
|
# 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
# This Makefile.in is free software; the Free Software Foundation
|
||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||
|
# with or without modifications, as long as this notice is preserved.
|
||||
|
|
||||
|
# This program is distributed in the hope that it will be useful,
|
||||
|
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
|
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
|
# PARTICULAR PURPOSE.
|
||||
|
|
||||
|
@SET_MAKE@ |
||||
|
|
||||
|
|
||||
|
srcdir = @srcdir@ |
||||
|
top_srcdir = @top_srcdir@ |
||||
|
VPATH = @srcdir@ |
||||
|
pkgdatadir = $(datadir)/@PACKAGE@ |
||||
|
pkglibdir = $(libdir)/@PACKAGE@ |
||||
|
pkgincludedir = $(includedir)/@PACKAGE@ |
||||
|
top_builddir = .. |
||||
|
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd |
||||
|
INSTALL = @INSTALL@ |
||||
|
install_sh_DATA = $(install_sh) -c -m 644 |
||||
|
install_sh_PROGRAM = $(install_sh) -c |
||||
|
install_sh_SCRIPT = $(install_sh) -c |
||||
|
INSTALL_HEADER = $(INSTALL_DATA) |
||||
|
transform = $(program_transform_name) |
||||
|
NORMAL_INSTALL = : |
||||
|
PRE_INSTALL = : |
||||
|
POST_INSTALL = : |
||||
|
NORMAL_UNINSTALL = : |
||||
|
PRE_UNINSTALL = : |
||||
|
POST_UNINSTALL = : |
||||
|
build_triplet = @build@ |
||||
|
host_triplet = @host@ |
||||
|
bin_PROGRAMS = tp4_comptesbancaires$(EXEEXT) |
||||
|
subdir = src |
||||
|
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
|
||||
|
$(srcdir)/Makefile.in |
||||
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
||||
|
am__aclocal_m4_deps = $(top_srcdir)/configure.in |
||||
|
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
|
$(ACLOCAL_M4) |
||||
|
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs |
||||
|
CONFIG_HEADER = $(top_builddir)/config.h |
||||
|
CONFIG_CLEAN_FILES = |
||||
|
am__installdirs = "$(DESTDIR)$(bindir)" |
||||
|
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) |
||||
|
PROGRAMS = $(bin_PROGRAMS) |
||||
|
am_tp4_comptesbancaires_OBJECTS = tp4_comptesbancaires.$(OBJEXT) \
|
||||
|
Compte.$(OBJEXT) CompteCheque.$(OBJEXT) Livret.$(OBJEXT) \
|
||||
|
PlanEpargneLogement.$(OBJEXT) Moneo.$(OBJEXT) Banque.$(OBJEXT) |
||||
|
tp4_comptesbancaires_OBJECTS = $(am_tp4_comptesbancaires_OBJECTS) |
||||
|
tp4_comptesbancaires_LDADD = $(LDADD) |
||||
|
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) |
||||
|
depcomp = $(SHELL) $(top_srcdir)/depcomp |
||||
|
am__depfiles_maybe = depfiles |
||||
|
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
|
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) |
||||
|
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \
|
||||
|
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
|
$(AM_CXXFLAGS) $(CXXFLAGS) |
||||
|
CXXLD = $(CXX) |
||||
|
CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
||||
|
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ |
||||
|
SOURCES = $(tp4_comptesbancaires_SOURCES) |
||||
|
DIST_SOURCES = $(tp4_comptesbancaires_SOURCES) |
||||
|
HEADERS = $(noinst_HEADERS) |
||||
|
ETAGS = etags |
||||
|
CTAGS = ctags |
||||
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
||||
|
ACLOCAL = @ACLOCAL@ |
||||
|
AMDEP_FALSE = @AMDEP_FALSE@ |
||||
|
AMDEP_TRUE = @AMDEP_TRUE@ |
||||
|
AMTAR = @AMTAR@ |
||||
|
AR = @AR@ |
||||
|
AUTOCONF = @AUTOCONF@ |
||||
|
AUTOHEADER = @AUTOHEADER@ |
||||
|
AUTOMAKE = @AUTOMAKE@ |
||||
|
AWK = @AWK@ |
||||
|
CC = @CC@ |
||||
|
CCDEPMODE = @CCDEPMODE@ |
||||
|
CFLAGS = @CFLAGS@ |
||||
|
CPP = @CPP@ |
||||
|
CPPFLAGS = @CPPFLAGS@ |
||||
|
CXX = @CXX@ |
||||
|
CXXCPP = @CXXCPP@ |
||||
|
CXXDEPMODE = @CXXDEPMODE@ |
||||
|
CXXFLAGS = @CXXFLAGS@ |
||||
|
CYGPATH_W = @CYGPATH_W@ |
||||
|
DEFS = @DEFS@ |
||||
|
DEPDIR = @DEPDIR@ |
||||
|
ECHO = @ECHO@ |
||||
|
ECHO_C = @ECHO_C@ |
||||
|
ECHO_N = @ECHO_N@ |
||||
|
ECHO_T = @ECHO_T@ |
||||
|
EGREP = @EGREP@ |
||||
|
EXEEXT = @EXEEXT@ |
||||
|
F77 = @F77@ |
||||
|
FFLAGS = @FFLAGS@ |
||||
|
INSTALL_DATA = @INSTALL_DATA@ |
||||
|
INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
||||
|
INSTALL_SCRIPT = @INSTALL_SCRIPT@ |
||||
|
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ |
||||
|
LDFLAGS = @LDFLAGS@ |
||||
|
LIBOBJS = @LIBOBJS@ |
||||
|
LIBS = @LIBS@ |
||||
|
LIBTOOL = @LIBTOOL@ |
||||
|
LN_S = @LN_S@ |
||||
|
LTLIBOBJS = @LTLIBOBJS@ |
||||
|
MAKEINFO = @MAKEINFO@ |
||||
|
OBJEXT = @OBJEXT@ |
||||
|
PACKAGE = @PACKAGE@ |
||||
|
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ |
||||
|
PACKAGE_NAME = @PACKAGE_NAME@ |
||||
|
PACKAGE_STRING = @PACKAGE_STRING@ |
||||
|
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
||||
|
PACKAGE_VERSION = @PACKAGE_VERSION@ |
||||
|
PATH_SEPARATOR = @PATH_SEPARATOR@ |
||||
|
RANLIB = @RANLIB@ |
||||
|
SET_MAKE = @SET_MAKE@ |
||||
|
SHELL = @SHELL@ |
||||
|
STRIP = @STRIP@ |
||||
|
VERSION = @VERSION@ |
||||
|
ac_ct_AR = @ac_ct_AR@ |
||||
|
ac_ct_CC = @ac_ct_CC@ |
||||
|
ac_ct_CXX = @ac_ct_CXX@ |
||||
|
ac_ct_F77 = @ac_ct_F77@ |
||||
|
ac_ct_RANLIB = @ac_ct_RANLIB@ |
||||
|
ac_ct_STRIP = @ac_ct_STRIP@ |
||||
|
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ |
||||
|
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ |
||||
|
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ |
||||
|
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ |
||||
|
am__include = @am__include@ |
||||
|
am__leading_dot = @am__leading_dot@ |
||||
|
am__quote = @am__quote@ |
||||
|
am__tar = @am__tar@ |
||||
|
am__untar = @am__untar@ |
||||
|
bindir = @bindir@ |
||||
|
build = @build@ |
||||
|
build_alias = @build_alias@ |
||||
|
build_cpu = @build_cpu@ |
||||
|
build_os = @build_os@ |
||||
|
build_vendor = @build_vendor@ |
||||
|
datadir = @datadir@ |
||||
|
exec_prefix = @exec_prefix@ |
||||
|
host = @host@ |
||||
|
host_alias = @host_alias@ |
||||
|
host_cpu = @host_cpu@ |
||||
|
host_os = @host_os@ |
||||
|
host_vendor = @host_vendor@ |
||||
|
includedir = @includedir@ |
||||
|
infodir = @infodir@ |
||||
|
install_sh = @install_sh@ |
||||
|
libdir = @libdir@ |
||||
|
libexecdir = @libexecdir@ |
||||
|
localstatedir = @localstatedir@ |
||||
|
mandir = @mandir@ |
||||
|
mkdir_p = @mkdir_p@ |
||||
|
oldincludedir = @oldincludedir@ |
||||
|
prefix = @prefix@ |
||||
|
program_transform_name = @program_transform_name@ |
||||
|
sbindir = @sbindir@ |
||||
|
sharedstatedir = @sharedstatedir@ |
||||
|
sysconfdir = @sysconfdir@ |
||||
|
target_alias = @target_alias@ |
||||
|
tp4_comptesbancaires_SOURCES = tp4_comptesbancaires.cpp Compte.cpp \
|
||||
|
CompteCheque.cpp Livret.cpp PlanEpargneLogement.cpp Moneo.cpp Banque.cpp |
||||
|
|
||||
|
|
||||
|
# set the include path found by configure
|
||||
|
INCLUDES = $(all_includes) |
||||
|
|
||||
|
# the library search path.
|
||||
|
tp4_comptesbancaires_LDFLAGS = $(all_libraries) |
||||
|
noinst_HEADERS = Compte.h CompteCheque.h Livret.h PlanEpargneLogement.h \
|
||||
|
Banque.h |
||||
|
|
||||
|
all: all-am |
||||
|
|
||||
|
.SUFFIXES: |
||||
|
.SUFFIXES: .cpp .lo .o .obj |
||||
|
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) |
||||
|
@for dep in $?; do \
|
||||
|
case '$(am__configure_deps)' in \
|
||||
|
*$$dep*) \
|
||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||
|
&& exit 0; \
|
||||
|
exit 1;; \
|
||||
|
esac; \
|
||||
|
done; \
|
||||
|
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
|
||||
|
cd $(top_srcdir) && \
|
||||
|
$(AUTOMAKE) --gnu src/Makefile |
||||
|
.PRECIOUS: Makefile |
||||
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
||||
|
@case '$?' in \
|
||||
|
*config.status*) \
|
||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
|
*) \
|
||||
|
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
|
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
|
esac; |
||||
|
|
||||
|
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) |
||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
||||
|
|
||||
|
$(top_srcdir)/configure: $(am__configure_deps) |
||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
||||
|
$(ACLOCAL_M4): $(am__aclocal_m4_deps) |
||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
||||
|
install-binPROGRAMS: $(bin_PROGRAMS) |
||||
|
@$(NORMAL_INSTALL) |
||||
|
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" |
||||
|
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
|
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
|
if test -f $$p \
|
||||
|
|| test -f $$p1 \
|
||||
|
; then \
|
||||
|
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
|
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
|
||||
|
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
|
||||
|
else :; fi; \
|
||||
|
done |
||||
|
|
||||
|
uninstall-binPROGRAMS: |
||||
|
@$(NORMAL_UNINSTALL) |
||||
|
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
|
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
|
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
|
||||
|
rm -f "$(DESTDIR)$(bindir)/$$f"; \
|
||||
|
done |
||||
|
|
||||
|
clean-binPROGRAMS: |
||||
|
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
|
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
|
echo " rm -f $$p $$f"; \
|
||||
|
rm -f $$p $$f ; \
|
||||
|
done |
||||
|
tp4_comptesbancaires$(EXEEXT): $(tp4_comptesbancaires_OBJECTS) $(tp4_comptesbancaires_DEPENDENCIES) |
||||
|
@rm -f tp4_comptesbancaires$(EXEEXT) |
||||
|
$(CXXLINK) $(tp4_comptesbancaires_LDFLAGS) $(tp4_comptesbancaires_OBJECTS) $(tp4_comptesbancaires_LDADD) $(LIBS) |
||||
|
|
||||
|
mostlyclean-compile: |
||||
|
-rm -f *.$(OBJEXT) |
||||
|
|
||||
|
distclean-compile: |
||||
|
-rm -f *.tab.c |
||||
|
|
||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Banque.Po@am__quote@ |
||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Compte.Po@am__quote@ |
||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CompteCheque.Po@am__quote@ |
||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Livret.Po@am__quote@ |
||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Moneo.Po@am__quote@ |
||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PlanEpargneLogement.Po@am__quote@ |
||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tp4_comptesbancaires.Po@am__quote@ |
||||
|
|
||||
|
.cpp.o: |
||||
|
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ |
||||
|
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi |
||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
||||
|
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< |
||||
|
|
||||
|
.cpp.obj: |
||||
|
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ |
||||
|
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi |
||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
||||
|
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` |
||||
|
|
||||
|
.cpp.lo: |
||||
|
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ |
||||
|
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi |
||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ |
||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
||||
|
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< |
||||
|
|
||||
|
mostlyclean-libtool: |
||||
|
-rm -f *.lo |
||||
|
|
||||
|
clean-libtool: |
||||
|
-rm -rf .libs _libs |
||||
|
|
||||
|
distclean-libtool: |
||||
|
-rm -f libtool |
||||
|
uninstall-info-am: |
||||
|
|
||||
|
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) |
||||
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
|
unique=`for i in $$list; do \
|
||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
|
done | \
|
||||
|
$(AWK) ' { files[$$0] = 1; } \
|
||||
|
END { for (i in files) print i; }'`; \
|
||||
|
mkid -fID $$unique |
||||
|
tags: TAGS |
||||
|
|
||||
|
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ |
||||
|
$(TAGS_FILES) $(LISP) |
||||
|
tags=; \
|
||||
|
here=`pwd`; \
|
||||
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
|
unique=`for i in $$list; do \
|
||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
|
done | \
|
||||
|
$(AWK) ' { files[$$0] = 1; } \
|
||||
|
END { for (i in files) print i; }'`; \
|
||||
|
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
|
test -n "$$unique" || unique=$$empty_fix; \
|
||||
|
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
|
$$tags $$unique; \
|
||||
|
fi |
||||
|
ctags: CTAGS |
||||
|
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ |
||||
|
$(TAGS_FILES) $(LISP) |
||||
|
tags=; \
|
||||
|
here=`pwd`; \
|
||||
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
|
unique=`for i in $$list; do \
|
||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
|
done | \
|
||||
|
$(AWK) ' { files[$$0] = 1; } \
|
||||
|
END { for (i in files) print i; }'`; \
|
||||
|
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
|
$$tags $$unique |
||||
|
|
||||
|
GTAGS: |
||||
|
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
|
&& cd $(top_srcdir) \
|
||||
|
&& gtags -i $(GTAGS_ARGS) $$here |
||||
|
|
||||
|
distclean-tags: |
||||
|
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags |
||||
|
|
||||
|
distdir: $(DISTFILES) |
||||
|
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
|
||||
|
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
|
||||
|
list='$(DISTFILES)'; for file in $$list; do \
|
||||
|
case $$file in \
|
||||
|
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
|
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
|
||||
|
esac; \
|
||||
|
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
|
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
|
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
|
||||
|
dir="/$$dir"; \
|
||||
|
$(mkdir_p) "$(distdir)$$dir"; \
|
||||
|
else \
|
||||
|
dir=''; \
|
||||
|
fi; \
|
||||
|
if test -d $$d/$$file; then \
|
||||
|
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
|
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
|
fi; \
|
||||
|
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
|
else \
|
||||
|
test -f $(distdir)/$$file \
|
||||
|
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|
|| exit 1; \
|
||||
|
fi; \
|
||||
|
done |
||||
|
check-am: all-am |
||||
|
check: check-am |
||||
|
all-am: Makefile $(PROGRAMS) $(HEADERS) |
||||
|
installdirs: |
||||
|
for dir in "$(DESTDIR)$(bindir)"; do \
|
||||
|
test -z "$$dir" || $(mkdir_p) "$$dir"; \
|
||||
|
done |
||||
|
install: install-am |
||||
|
install-exec: install-exec-am |
||||
|
install-data: install-data-am |
||||
|
uninstall: uninstall-am |
||||
|
|
||||
|
install-am: all-am |
||||
|
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am |
||||
|
|
||||
|
installcheck: installcheck-am |
||||
|
install-strip: |
||||
|
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
|
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
|
`test -z '$(STRIP)' || \
|
||||
|
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install |
||||
|
mostlyclean-generic: |
||||
|
|
||||
|
clean-generic: |
||||
|
|
||||
|
distclean-generic: |
||||
|
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) |
||||
|
|
||||
|
maintainer-clean-generic: |
||||
|
@echo "This command is intended for maintainers to use" |
||||
|
@echo "it deletes files that may require special tools to rebuild." |
||||
|
clean: clean-am |
||||
|
|
||||
|
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am |
||||
|
|
||||
|
distclean: distclean-am |
||||
|
-rm -rf ./$(DEPDIR) |
||||
|
-rm -f Makefile |
||||
|
distclean-am: clean-am distclean-compile distclean-generic \ |
||||
|
distclean-libtool distclean-tags |
||||
|
|
||||
|
dvi: dvi-am |
||||
|
|
||||
|
dvi-am: |
||||
|
|
||||
|
html: html-am |
||||
|
|
||||
|
info: info-am |
||||
|
|
||||
|
info-am: |
||||
|
|
||||
|
install-data-am: |
||||
|
|
||||
|
install-exec-am: install-binPROGRAMS |
||||
|
|
||||
|
install-info: install-info-am |
||||
|
|
||||
|
install-man: |
||||
|
|
||||
|
installcheck-am: |
||||
|
|
||||
|
maintainer-clean: maintainer-clean-am |
||||
|
-rm -rf ./$(DEPDIR) |
||||
|
-rm -f Makefile |
||||
|
maintainer-clean-am: distclean-am maintainer-clean-generic |
||||
|
|
||||
|
mostlyclean: mostlyclean-am |
||||
|
|
||||
|
mostlyclean-am: mostlyclean-compile mostlyclean-generic \ |
||||
|
mostlyclean-libtool |
||||
|
|
||||
|
pdf: pdf-am |
||||
|
|
||||
|
pdf-am: |
||||
|
|
||||
|
ps: ps-am |
||||
|
|
||||
|
ps-am: |
||||
|
|
||||
|
uninstall-am: uninstall-binPROGRAMS uninstall-info-am |
||||
|
|
||||
|
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ |
||||
|
clean-generic clean-libtool ctags distclean distclean-compile \
|
||||
|
distclean-generic distclean-libtool distclean-tags distdir dvi \
|
||||
|
dvi-am html html-am info info-am install install-am \
|
||||
|
install-binPROGRAMS install-data install-data-am install-exec \
|
||||
|
install-exec-am install-info install-info-am install-man \
|
||||
|
install-strip installcheck installcheck-am installdirs \
|
||||
|
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
|
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||
|
pdf pdf-am ps ps-am tags uninstall uninstall-am \
|
||||
|
uninstall-binPROGRAMS uninstall-info-am |
||||
|
|
||||
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
.NOEXPORT: |
||||
@ -0,0 +1,154 @@ |
|||||
|
/**
|
||||
|
* #(@)Moneo.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Implémentation de la classe Moneo. |
||||
|
*/ |
||||
|
|
||||
|
#include "Moneo.h" |
||||
|
#include <sstream> |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Définition des constructeurs/destructeur |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
Moneo::Moneo(CompteCheque & cpt, double soldeMax) { |
||||
|
this->setCompte(cpt); |
||||
|
this->setSoldeMax(soldeMax); |
||||
|
this->setSolde(0); |
||||
|
std::cout << *this << ": Moneo::Moneo(" << cpt << ", soldeMax: " << soldeMax << ")" << std::endl; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Moneo::~Moneo() { |
||||
|
double montant = this->solde(); |
||||
|
this->compte().depose(montant); |
||||
|
std::cout << *this << ": Moneo::~Moneo()" << std::endl; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Opérations bancaires. |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
bool Moneo::recharge() { |
||||
|
bool ret = false; |
||||
|
double montant = this->soldeMax() - this->solde(); |
||||
|
|
||||
|
if (this->compte().retrait(montant)) { |
||||
|
cout << *this << ": Moneo::recharge() => " << montant << std::endl; |
||||
|
this->setSolde(this->soldeMax()); |
||||
|
ret = true; |
||||
|
} else { |
||||
|
cout << *this << ": Moneo::recharge() opération impossible, solde compte trop faible" << std::endl; |
||||
|
} |
||||
|
|
||||
|
return ret; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool Moneo::retrait(double montant) { |
||||
|
bool ret = false; |
||||
|
|
||||
|
if (montant < 0) { |
||||
|
cerr << *this << ": Moneo::retrait(" << montant << "): ne peut retirer un montant négatif." << endl; |
||||
|
} else if (montant > this->solde()) { |
||||
|
cerr << *this << ": Moneo::retrait(" << montant << "): solde trop faible." << endl; |
||||
|
} else { |
||||
|
cout << *this << ": Moneo::retrait(" << montant << ")" << endl; |
||||
|
this->setSolde(this->solde() - montant); |
||||
|
ret = true; |
||||
|
} |
||||
|
|
||||
|
return ret; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Définition des accesseurs |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
CompteCheque & Moneo::compte() const { |
||||
|
return *_compte; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void Moneo::setCompte(CompteCheque & cpt) { |
||||
|
_compte = &cpt; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
double Moneo::solde() const { |
||||
|
return _solde; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void Moneo::setSolde(double theValue) { |
||||
|
_solde = theValue; |
||||
|
} |
||||
|
|
||||
|
double Moneo::soldeMax() const { |
||||
|
return _soldeMax; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void Moneo::setSoldeMax(double theValue) { |
||||
|
_soldeMax = theValue; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Méthodes utilitaires. |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
string Moneo::toString() const { |
||||
|
ostringstream oss; |
||||
|
|
||||
|
oss << "Moneo(soldeMax = "; |
||||
|
oss << this->soldeMax(); |
||||
|
oss << ", solde = "; |
||||
|
oss << this->solde(); |
||||
|
oss << ", compte = "; |
||||
|
oss << this->compte(); |
||||
|
oss << ")"; |
||||
|
|
||||
|
return oss.str(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Fonctions |
||||
|
* |
||||
|
*/ |
||||
|
std::ostream & operator<<(std::ostream & st, const Moneo & cpt) { |
||||
|
st << cpt.toString(); |
||||
|
return st; |
||||
|
} |
||||
@ -0,0 +1,148 @@ |
|||||
|
/**
|
||||
|
* #(@)Moneo.h ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* TP Compte bancaire |
||||
|
*/ |
||||
|
|
||||
|
#ifndef MONEO_H |
||||
|
#define MONEO_H |
||||
|
|
||||
|
#include <string> |
||||
|
#include <iostream> |
||||
|
#include "CompteCheque.h" |
||||
|
|
||||
|
/**
|
||||
|
* Représente un porte monnaie monéo. |
||||
|
*/ |
||||
|
class Moneo { |
||||
|
|
||||
|
public: |
||||
|
/*
|
||||
|
* |
||||
|
* Constructeurs/destructeur |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Construit un porte monnaie Moneo |
||||
|
*/ |
||||
|
Moneo(CompteCheque & cpt, double soldeMax); |
||||
|
|
||||
|
/**
|
||||
|
* Détruit un porte monnaie Moneo: le montant contenu dans le |
||||
|
* porte monnaie est reversé sur le compte associé |
||||
|
*/ |
||||
|
~Moneo(); |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Getteurs |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Retourne le compte chèque associé. |
||||
|
*/ |
||||
|
CompteCheque & compte() const; |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le solde de ce porte monnaie. |
||||
|
*/ |
||||
|
double solde() const; |
||||
|
|
||||
|
/**
|
||||
|
* Retourne une représentation textuelle de ce compte. |
||||
|
*/ |
||||
|
std::string toString() const; |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* |
||||
|
* Opérations bancaires |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Recharge le porte monnaie d'un montant (nécessairement positif). |
||||
|
* |
||||
|
* @param montant le montant à déposer. |
||||
|
*/ |
||||
|
bool recharge(double montant); |
||||
|
|
||||
|
/**
|
||||
|
* Recharge le porte monnaie à son solde maximum. |
||||
|
* |
||||
|
*/ |
||||
|
bool recharge(); |
||||
|
|
||||
|
/**
|
||||
|
* Retire un montant (nécessairement positif) de ce porte monnaie. |
||||
|
* |
||||
|
* @param montant le montant à retirer. |
||||
|
*/ |
||||
|
bool retrait(double montant); |
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/**
|
||||
|
* Definit le solde de ce compte. |
||||
|
*/ |
||||
|
void setSolde(double theValue); |
||||
|
|
||||
|
/**
|
||||
|
* Definit le solde maximum de ce compte. |
||||
|
*/ |
||||
|
void setSoldeMax(double theValue); |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le solde maximum de ce porte monnaie. |
||||
|
*/ |
||||
|
double soldeMax() const; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Definit le compte chèque associé. |
||||
|
*/ |
||||
|
void setCompte(CompteCheque & theValue); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Le compte chèque associé, ne peut pas être null. |
||||
|
*/ |
||||
|
CompteCheque * _compte; |
||||
|
|
||||
|
/**
|
||||
|
* Le solde de ce compte, ne peut pas être négatif. |
||||
|
*/ |
||||
|
double _solde; |
||||
|
|
||||
|
/**
|
||||
|
* Le solde maximum de ce compte, ne peut pas être négatif. |
||||
|
*/ |
||||
|
double _soldeMax; |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
/**
|
||||
|
* Affiche un porte monnaie Monéo sur un flux de sortie |
||||
|
*/ |
||||
|
std::ostream & operator<<(std::ostream & st, const Moneo & cpt); |
||||
|
|
||||
|
#endif /* MONEO_H */ |
||||
@ -0,0 +1,96 @@ |
|||||
|
/**
|
||||
|
* #(@)PlanEpargneLogement.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Implémentation de la classe PlanEpargneLogement. |
||||
|
*/ |
||||
|
|
||||
|
/*
|
||||
|
* @Fait tout |
||||
|
* |
||||
|
* @Afaire - |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
|
#include "PlanEpargneLogement.h" |
||||
|
#include <sstream> |
||||
|
|
||||
|
double PlanEpargneLogement::_coefficient = 1; |
||||
|
|
||||
|
PlanEpargneLogement::PlanEpargneLogement( std::string nom, double taux, double solde ) : Livret(nom, taux, solde) { |
||||
|
std::cout << *this << ": PlanEpargneLogement::PlanEpargneLogement(\"" << nom << "\", taux: " << taux << ", solde: " << solde << ")" << std::endl; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
PlanEpargneLogement::~PlanEpargneLogement() { |
||||
|
std::cout << *this << ": PlanEpargneLogement::~PlanEpargneLogement()" << std::endl; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool PlanEpargneLogement::retrait( double montant ) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if (montant == this->solde()) { |
||||
|
result = Livret::retrait(montant); |
||||
|
} else { |
||||
|
std::cerr << *this << ": PlanEpargneLogement::retrait(" << montant << ") : erreur, le montant du retait doit être égal au solde" << std::endl; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
std::string PlanEpargneLogement::toString( ) const { |
||||
|
std::ostringstream oss; |
||||
|
|
||||
|
oss << "Plan-Epargne-Logement(numeroCompte = "; |
||||
|
oss << this->numeroDeCompte(); |
||||
|
oss << ", nomProprietaire = "; |
||||
|
oss << this->nomProprietaire(); |
||||
|
oss << ", solde = "; |
||||
|
oss << this->solde(); |
||||
|
oss << ", taux: "; |
||||
|
oss << this->taux(); |
||||
|
oss << ")"; |
||||
|
return oss.str(); |
||||
|
} |
||||
|
|
||||
|
double PlanEpargneLogement::coefficient() { |
||||
|
return PlanEpargneLogement::_coefficient; |
||||
|
} |
||||
|
|
||||
|
bool PlanEpargneLogement::setCoefficient(double coef) { |
||||
|
bool result = false; |
||||
|
|
||||
|
if (coef >= 0) { |
||||
|
_coefficient = coef; |
||||
|
result = true; |
||||
|
} else { |
||||
|
std::cerr << "PlanEpargneLogement::setCoefficient(" << coef << ")" << std::endl; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
double PlanEpargneLogement::taux() const { |
||||
|
return Livret::taux() * PlanEpargneLogement::coefficient(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
@ -0,0 +1,102 @@ |
|||||
|
/**
|
||||
|
* #(@)PlanEpargneLogement.h ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Déclaration de la classe PlanEpargneLogement. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
#ifndef PLANEPARGNELOGEMENT_H |
||||
|
#define PLANEPARGNELOGEMENT_H |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
#include "Livret.h" |
||||
|
|
||||
|
/**
|
||||
|
* Represente un plan epargne logement. |
||||
|
* |
||||
|
* @author Nicolas MASSE |
||||
|
* @author Thomas LIMIN |
||||
|
*/ |
||||
|
class PlanEpargneLogement : public Livret { |
||||
|
|
||||
|
public: |
||||
|
|
||||
|
/**
|
||||
|
* Constructeur de plan epargne logement. |
||||
|
* |
||||
|
* @param nom le nom du titulaire du compte |
||||
|
* @param taux le taux d'intêret |
||||
|
* @param solde le solde initial du compte |
||||
|
*/ |
||||
|
PlanEpargneLogement(std::string nom, double taux = 0, double solde = 0); |
||||
|
|
||||
|
/**
|
||||
|
* Destructeur |
||||
|
*/ |
||||
|
~PlanEpargneLogement(); |
||||
|
|
||||
|
/**
|
||||
|
* Retrait. Sur un PEL, il est impossible d'avoir un solde négatif. |
||||
|
* De plus le seul montant de retrait autorisé est le solde du PEL |
||||
|
* La méthode de retrait prend en compte ces restrictions |
||||
|
* |
||||
|
* @param montant le montant du retrait |
||||
|
* @return true si le retrait a bien été effectué |
||||
|
*/ |
||||
|
bool retrait(double montant); |
||||
|
|
||||
|
/**
|
||||
|
* Retourne le taux d'interêt. Pour un PEL, il correspond |
||||
|
* au taux initial multiplié par le coefficient global |
||||
|
* |
||||
|
* @return le taux; |
||||
|
*/ |
||||
|
double taux() const; |
||||
|
|
||||
|
/**
|
||||
|
* Retourne une représentation textuelle de ce compte. |
||||
|
*/ |
||||
|
std::string toString() const; |
||||
|
|
||||
|
/**
|
||||
|
* Permet de modifier le coefficient général |
||||
|
* le coefficient doit être >= 0 |
||||
|
* |
||||
|
* @param coef le nouveau coefficient |
||||
|
* @return true si ok |
||||
|
*/ |
||||
|
static bool setCoefficient(double coef); |
||||
|
|
||||
|
|
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/**
|
||||
|
* Pour récupérer le coefficient |
||||
|
* |
||||
|
* @return le coefficient actuel |
||||
|
*/ |
||||
|
static double coefficient(); |
||||
|
|
||||
|
/**
|
||||
|
* le coefficient qui est appliqué au taux de toutes les instance de PlanEpargneLogement |
||||
|
* il est initialisé à 1 lors du chargement de la classe. |
||||
|
*/ |
||||
|
static double _coefficient; |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,49 @@ |
|||||
|
/**
|
||||
|
* #(@)nomfichier.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Description des objectifs du programme, le sujet a traiter. |
||||
|
* Pour le programme qui contient le main(), |
||||
|
* la ligne de commande pour executer le programme. |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
/**
|
||||
|
* Description succinte de l'algorithme utilise comme solution. |
||||
|
* Eventuellement: Les references (cahier des charges,bibliographiques...). |
||||
|
*/ |
||||
|
|
||||
|
/*
|
||||
|
* @version 0.0.1 |
||||
|
* |
||||
|
* @Fait Detail de ce qui a ete fait. |
||||
|
* |
||||
|
* @Afaire Detail de ce qui n'a pas ete fait. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
|
#include "comptes.h" |
||||
|
|
||||
|
Comptes::Comptes() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Comptes::~Comptes() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
|
||||
@ -0,0 +1,52 @@ |
|||||
|
/**
|
||||
|
* #(@)nomfichier.h ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Description des objectifs du programme, le sujet a traiter. |
||||
|
* Pour le programme qui contient le main(), |
||||
|
* la ligne de commande pour executer le programme. |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
/**
|
||||
|
* Description succinte de l'algorithme utilise comme solution. |
||||
|
* Eventuellement: Les references (cahier des charges,bibliographiques...). |
||||
|
*/ |
||||
|
|
||||
|
/*
|
||||
|
* @version 0.0.1 |
||||
|
* |
||||
|
* @Fait Detail de ce qui a ete fait. |
||||
|
* |
||||
|
* @Afaire Detail de ce qui n'a pas ete fait. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
|
#ifndef COMPTES_H |
||||
|
#define COMPTES_H |
||||
|
|
||||
|
/**
|
||||
|
@author Nicolas MASSE |
||||
|
*/ |
||||
|
class Comptes{ |
||||
|
public: |
||||
|
Comptes(); |
||||
|
|
||||
|
~Comptes(); |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,55 @@ |
|||||
|
/**
|
||||
|
* #(@)tp4_comptesbancaires.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Programme de test du TP4 |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
/*
|
||||
|
* @Fait tout |
||||
|
* |
||||
|
* @Afaire - |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
#ifdef HAVE_CONFIG_H |
||||
|
#include <config.h> |
||||
|
#endif |
||||
|
|
||||
|
#include <iostream> |
||||
|
#include <cstdlib> |
||||
|
#include <ctime> |
||||
|
|
||||
|
#include "Banque.h" |
||||
|
#include "PlanEpargneLogement.h" |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
int main(int argc, char *argv[]) { |
||||
|
|
||||
|
PlanEpargneLogement::setCoefficient(0.5); |
||||
|
srand(time(0)); |
||||
|
|
||||
|
Banque b; |
||||
|
|
||||
|
std::cout << std::endl << std::endl << "Somme des soldes: " << b.calculeSommeSolde() << std::endl << std::endl; |
||||
|
std::cout << std::endl << std::endl << "Constance des soldes: " << b.effectueVirements(50) << std::endl << std::endl; |
||||
|
|
||||
|
return EXIT_SUCCESS; |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
/** |
||||
|
* #(@)nomfichier.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/** |
||||
|
* Description des objectifs du programme, le sujet a traiter. |
||||
|
* Pour le programme qui contient le main(), |
||||
|
* la ligne de commande pour executer le programme. |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
/** |
||||
|
* Description succinte de l'algorithme utilise comme solution. |
||||
|
* Eventuellement: Les references (cahier des charges,bibliographiques...). |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
* @version 0.0.1 |
||||
|
* |
||||
|
* @Fait Detail de ce qui a ete fait. |
||||
|
* |
||||
|
* @Afaire Detail de ce qui n'a pas ete fait. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
@ -0,0 +1,37 @@ |
|||||
|
/** |
||||
|
* #(@)nomfichier.h ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/** |
||||
|
* Description des objectifs du programme, le sujet a traiter. |
||||
|
* Pour le programme qui contient le main(), |
||||
|
* la ligne de commande pour executer le programme. |
||||
|
*/ |
||||
|
|
||||
|
#include <iostream> |
||||
|
|
||||
|
/** |
||||
|
* Description succinte de l'algorithme utilise comme solution. |
||||
|
* Eventuellement: Les references (cahier des charges,bibliographiques...). |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
* @version 0.0.1 |
||||
|
* |
||||
|
* @Fait Detail de ce qui a ete fait. |
||||
|
* |
||||
|
* @Afaire Detail de ce qui n'a pas ete fait. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
@ -0,0 +1,195 @@ |
|||||
|
<?xml version = '1.0'?> |
||||
|
<kdevelop> |
||||
|
<general> |
||||
|
<author>Nicolas MASSE</author> |
||||
|
<email>nicolas27.masse@laposte.net</email> |
||||
|
<version>0.1</version> |
||||
|
<projectmanagement>KDevAutoProject</projectmanagement> |
||||
|
<primarylanguage>C++</primarylanguage> |
||||
|
<keywords> |
||||
|
<keyword>C++</keyword> |
||||
|
<keyword>Code</keyword> |
||||
|
</keywords> |
||||
|
<ignoreparts> |
||||
|
<part>kdevbookmarks</part> |
||||
|
</ignoreparts> |
||||
|
<projectdirectory>.</projectdirectory> |
||||
|
<absoluteprojectpath>false</absoluteprojectpath> |
||||
|
<description/> |
||||
|
<versioncontrol/> |
||||
|
</general> |
||||
|
<kdevautoproject> |
||||
|
<general> |
||||
|
<activetarget>src/tp4_comptesbancaires</activetarget> |
||||
|
<useconfiguration>debug</useconfiguration> |
||||
|
<useactivetarget>true</useactivetarget> |
||||
|
</general> |
||||
|
<run> |
||||
|
<mainprogram>src/tp4_comptesbancaires</mainprogram> |
||||
|
<terminal>true</terminal> |
||||
|
<directoryradio>executable</directoryradio> |
||||
|
</run> |
||||
|
<configurations> |
||||
|
<optimized> |
||||
|
<builddir>optimized</builddir> |
||||
|
<ccompiler>kdevgccoptions</ccompiler> |
||||
|
<cxxcompiler>kdevgppoptions</cxxcompiler> |
||||
|
<f77compiler>kdevg77options</f77compiler> |
||||
|
<cxxflags>-O2 -g0</cxxflags> |
||||
|
</optimized> |
||||
|
<debug> |
||||
|
<configargs>--enable-debug=full</configargs> |
||||
|
<builddir>debug</builddir> |
||||
|
<ccompiler>kdevgccoptions</ccompiler> |
||||
|
<cxxcompiler>kdevgppoptions</cxxcompiler> |
||||
|
<f77compiler>kdevg77options</f77compiler> |
||||
|
<cxxflags>-O0 -g3 -Wall</cxxflags> |
||||
|
<envvars/> |
||||
|
<topsourcedir/> |
||||
|
<cppflags/> |
||||
|
<ldflags/> |
||||
|
<ccompilerbinary/> |
||||
|
<cxxcompilerbinary/> |
||||
|
<f77compilerbinary/> |
||||
|
<cflags/> |
||||
|
<f77flags/> |
||||
|
</debug> |
||||
|
</configurations> |
||||
|
<make> |
||||
|
<envvars> |
||||
|
<envvar value="1" name="WANT_AUTOCONF_2_5" /> |
||||
|
<envvar value="1" name="WANT_AUTOMAKE_1_6" /> |
||||
|
</envvars> |
||||
|
</make> |
||||
|
</kdevautoproject> |
||||
|
<kdevdoctreeview> |
||||
|
<ignoretocs> |
||||
|
<toc>ada</toc> |
||||
|
<toc>ada_bugs_gcc</toc> |
||||
|
<toc>bash</toc> |
||||
|
<toc>bash_bugs</toc> |
||||
|
<toc>clanlib</toc> |
||||
|
<toc>w3c-dom-level2-html</toc> |
||||
|
<toc>fortran_bugs_gcc</toc> |
||||
|
<toc>gnome1</toc> |
||||
|
<toc>gnustep</toc> |
||||
|
<toc>gtk</toc> |
||||
|
<toc>gtk_bugs</toc> |
||||
|
<toc>haskell</toc> |
||||
|
<toc>haskell_bugs_ghc</toc> |
||||
|
<toc>java_bugs_gcc</toc> |
||||
|
<toc>java_bugs_sun</toc> |
||||
|
<toc>kde2book</toc> |
||||
|
<toc>opengl</toc> |
||||
|
<toc>pascal_bugs_fp</toc> |
||||
|
<toc>php</toc> |
||||
|
<toc>php_bugs</toc> |
||||
|
<toc>perl</toc> |
||||
|
<toc>perl_bugs</toc> |
||||
|
<toc>python</toc> |
||||
|
<toc>python_bugs</toc> |
||||
|
<toc>qt-kdev3</toc> |
||||
|
<toc>ruby</toc> |
||||
|
<toc>ruby_bugs</toc> |
||||
|
<toc>sdl</toc> |
||||
|
<toc>w3c-svg</toc> |
||||
|
<toc>sw</toc> |
||||
|
<toc>w3c-uaag10</toc> |
||||
|
<toc>wxwidgets_bugs</toc> |
||||
|
</ignoretocs> |
||||
|
<ignoreqt_xml> |
||||
|
<toc>Guide to the Qt Translation Tools</toc> |
||||
|
<toc>Qt Assistant Manual</toc> |
||||
|
<toc>Qt Designer Manual</toc> |
||||
|
<toc>Qt Reference Documentation</toc> |
||||
|
<toc>qmake User Guide</toc> |
||||
|
</ignoreqt_xml> |
||||
|
<ignoredoxygen> |
||||
|
<toc>KDE Libraries (Doxygen)</toc> |
||||
|
</ignoredoxygen> |
||||
|
</kdevdoctreeview> |
||||
|
<kdevfilecreate> |
||||
|
<useglobaltypes> |
||||
|
<type ext="cpp" /> |
||||
|
<type ext="h" /> |
||||
|
</useglobaltypes> |
||||
|
</kdevfilecreate> |
||||
|
<kdevfileview> |
||||
|
<groups> |
||||
|
<group pattern="*.h" name="Header files" /> |
||||
|
<group pattern="*.cpp" name="Source files" /> |
||||
|
<hidenonprojectfiles>false</hidenonprojectfiles> |
||||
|
<hidenonlocation>false</hidenonlocation> |
||||
|
</groups> |
||||
|
<tree> |
||||
|
<hidepatterns>*.o,*.lo,CVS</hidepatterns> |
||||
|
<hidenonprojectfiles>false</hidenonprojectfiles> |
||||
|
</tree> |
||||
|
</kdevfileview> |
||||
|
<kdevdocumentation> |
||||
|
<projectdoc> |
||||
|
<docsystem>Doxygen Documentation Collection</docsystem> |
||||
|
<docurl>tp4_comptesbancaires.tag</docurl> |
||||
|
</projectdoc> |
||||
|
</kdevdocumentation> |
||||
|
<substmap> |
||||
|
<APPNAME>TP4_ComptesBancaires</APPNAME> |
||||
|
<APPNAMELC>tp4_comptesbancaires</APPNAMELC> |
||||
|
<APPNAMESC>TP4_ComptesBancaires</APPNAMESC> |
||||
|
<APPNAMEUC>TP4_COMPTESBANCAIRES</APPNAMEUC> |
||||
|
<AUTHOR>Nicolas MASSE</AUTHOR> |
||||
|
<EMAIL>nicolas27.masse@laposte.net</EMAIL> |
||||
|
<LICENSE>GPL</LICENSE> |
||||
|
<LICENSEFILE>COPYING</LICENSEFILE> |
||||
|
<VERSION>0.1</VERSION> |
||||
|
<YEAR>2005</YEAR> |
||||
|
<dest>/home/nicolas/repository/ENSI_2ndY/Cpp/tp4_comptesbancaires</dest> |
||||
|
</substmap> |
||||
|
<kdevcppsupport> |
||||
|
<references/> |
||||
|
<codecompletion> |
||||
|
<includeGlobalFunctions>true</includeGlobalFunctions> |
||||
|
<includeTypes>true</includeTypes> |
||||
|
<includeEnums>true</includeEnums> |
||||
|
<includeTypedefs>false</includeTypedefs> |
||||
|
<automaticCodeCompletion>true</automaticCodeCompletion> |
||||
|
<automaticArgumentsHint>true</automaticArgumentsHint> |
||||
|
<automaticHeaderCompletion>true</automaticHeaderCompletion> |
||||
|
<codeCompletionDelay>250</codeCompletionDelay> |
||||
|
<argumentsHintDelay>400</argumentsHintDelay> |
||||
|
<headerCompletionDelay>250</headerCompletionDelay> |
||||
|
</codecompletion> |
||||
|
<creategettersetter> |
||||
|
<prefixGet/> |
||||
|
<prefixSet>set</prefixSet> |
||||
|
<prefixVariable>m_,_</prefixVariable> |
||||
|
<parameterName>theValue</parameterName> |
||||
|
<inlineGet>false</inlineGet> |
||||
|
<inlineSet>true</inlineSet> |
||||
|
</creategettersetter> |
||||
|
</kdevcppsupport> |
||||
|
<cppsupportpart> |
||||
|
<filetemplates> |
||||
|
<interfacesuffix>.h</interfacesuffix> |
||||
|
<implementationsuffix>.cpp</implementationsuffix> |
||||
|
</filetemplates> |
||||
|
</cppsupportpart> |
||||
|
<kdevdebugger> |
||||
|
<general> |
||||
|
<programargs/> |
||||
|
<gdbpath/> |
||||
|
<dbgshell>libtool</dbgshell> |
||||
|
<configGdbScript/> |
||||
|
<runShellScript/> |
||||
|
<runGdbScript/> |
||||
|
<breakonloadinglibs>true</breakonloadinglibs> |
||||
|
<separatetty>false</separatetty> |
||||
|
<floatingtoolbar>false</floatingtoolbar> |
||||
|
</general> |
||||
|
<display> |
||||
|
<staticmembers>false</staticmembers> |
||||
|
<demanglenames>true</demanglenames> |
||||
|
<outputradix>10</outputradix> |
||||
|
</display> |
||||
|
</kdevdebugger> |
||||
|
</kdevelop> |
||||
Binary file not shown.
@ -0,0 +1,20 @@ |
|||||
|
<?xml version = '1.0' encoding = 'UTF-8'?> |
||||
|
<!DOCTYPE KDevPrjSession> |
||||
|
<KDevPrjSession> |
||||
|
<DocsAndViews NumberOfDocuments="0" /> |
||||
|
<pluginList> |
||||
|
<kdevdebugger> |
||||
|
<breakpointList> |
||||
|
<breakpoint0 location="/home/limint/ENSI/2A/C++/tp4_comptesbancaires/src/Livret.h:124" type="1" tracingFormatString="" traceFormatStringEnabled="0" condition="" tracingEnabled="0" enabled="1" > |
||||
|
<tracedExpressions/> |
||||
|
</breakpoint0> |
||||
|
</breakpointList> |
||||
|
</kdevdebugger> |
||||
|
<kdevvalgrind> |
||||
|
<executable path="" params="" /> |
||||
|
<valgrind path="" params="" /> |
||||
|
<calltree path="" params="" /> |
||||
|
<kcachegrind path="" /> |
||||
|
</kdevvalgrind> |
||||
|
</pluginList> |
||||
|
</KDevPrjSession> |
||||
@ -0,0 +1,619 @@ |
|||||
|
/**
|
||||
|
* @file Ensemble.hh |
||||
|
* @author Nicolas MASSE & Thomas LIMIN |
||||
|
* @date Thu Nov 18 |
||||
|
* |
||||
|
* @brief Declaration de la classe parametree Ensemble. |
||||
|
* |
||||
|
*/ |
||||
|
#ifndef ENSEMBLE_H |
||||
|
#define ENSEMBLE_H |
||||
|
|
||||
|
#include <iostream> |
||||
|
#include <ostream> |
||||
|
|
||||
|
/* using namespace std;
|
||||
|
* |
||||
|
* NOTE : |
||||
|
* Ce fichier d'en-tete ne comporte pas de directive using, bien que la version |
||||
|
* fournie en comporte. En effet, l'usage de cette directive dans un fichier |
||||
|
* d'en-tete (dont la finalite est d'etre inclus dans un fichier source) peut creer |
||||
|
* des conflits d'espace de noms dans les fichiers l'incluant. On preferera |
||||
|
* l'utilisation des prefixe d'espace de noms |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Extension (iterateur, foncteur) |
||||
|
* Classe foncteur. Ses instances peuvent etre appelees |
||||
|
* comme des fonctions race à la surcharge de l'opérateur () |
||||
|
* l'implémentation courante retourne le double de l'element |
||||
|
* passé a cette fonction |
||||
|
*/ |
||||
|
|
||||
|
template <typename T> |
||||
|
|
||||
|
class Foncteur { |
||||
|
|
||||
|
public: |
||||
|
|
||||
|
/**
|
||||
|
* Constructeur. Permet de definir le coefficient de multiplication |
||||
|
* propre au foncteur |
||||
|
* |
||||
|
* @param coef le coefficient |
||||
|
*/ |
||||
|
Foncteur(double coef) : _coef(coef) {} |
||||
|
|
||||
|
/**
|
||||
|
* Une methode foncteur, retourne le double de l'elemet |
||||
|
* passe en parametre. Ceci ne fonctionne que pour les |
||||
|
* types de données qpossédant un opérateur * |
||||
|
* |
||||
|
* @param e l'element a traiter |
||||
|
* @return l'element retourne |
||||
|
*/ |
||||
|
T operator() (const T & e) { |
||||
|
return e * _coef; |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
|
||||
|
double _coef; |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Classe permettant de representer un ensemble d'elements |
||||
|
* en utilisant uniquement la notion d'egalite entre elements |
||||
|
* Aucune relation d'ordre n'est utilisee (par exemple |
||||
|
* pour avoir un representation ordonnee en memoire qui accelererait |
||||
|
* les recherches).<br> |
||||
|
* Seul l'operateur == est utilise pour tester l'egalite de deux |
||||
|
* elements. |
||||
|
*/ |
||||
|
|
||||
|
template <typename T> |
||||
|
|
||||
|
class Ensemble { |
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/**
|
||||
|
* Concept de noeud d'une liste chainée. Cette clase est définnie a l'interieur |
||||
|
* de la classe ensemble, ce qui permet d'en limiter la portée a la classe |
||||
|
* Ensemble |
||||
|
*/ |
||||
|
|
||||
|
class Noeud { |
||||
|
|
||||
|
private: |
||||
|
T _valeur; |
||||
|
Noeud * _suivant; |
||||
|
|
||||
|
public: |
||||
|
Noeud(const T & valeur, Noeud * suivant = 0) : _valeur(valeur), _suivant(suivant) { } |
||||
|
|
||||
|
Noeud(const Noeud & n) { |
||||
|
_valeur = n.getValeur(); |
||||
|
|
||||
|
if (n.aUnSuivant()) { |
||||
|
_suivant = new Noeud(*n.getSuivant()); |
||||
|
} else { |
||||
|
_suivant = 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
~Noeud() { |
||||
|
delete _suivant; |
||||
|
} |
||||
|
|
||||
|
const T & getValeur() const { |
||||
|
return _valeur; |
||||
|
} |
||||
|
|
||||
|
Noeud * getSuivant() const { |
||||
|
return _suivant; |
||||
|
} |
||||
|
|
||||
|
void setSuivant(Noeud * suivant) { |
||||
|
_suivant = suivant; |
||||
|
} |
||||
|
|
||||
|
bool aUnSuivant() const { |
||||
|
return _suivant != 0; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Methode recursive de suppression d'un element dans |
||||
|
* une liste chainee. |
||||
|
* |
||||
|
* @param liste une liste. |
||||
|
* @param x un element. |
||||
|
* |
||||
|
* @return le liste sans l'element. |
||||
|
*/ |
||||
|
Noeud * retire(const T & x) { |
||||
|
|
||||
|
Noeud * ret = this; |
||||
|
|
||||
|
if (this->getValeur() == x) { |
||||
|
// On l'a trouve !
|
||||
|
ret = this->getSuivant(); |
||||
|
this->setSuivant(0); |
||||
|
delete this; |
||||
|
} else if (this->aUnSuivant()) { |
||||
|
// Il y a un suivant.
|
||||
|
this->setSuivant(this->getSuivant()->retire(x)); |
||||
|
} |
||||
|
|
||||
|
return ret; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Concept d'iterateur d'une liste. |
||||
|
*/ |
||||
|
|
||||
|
class Iterateur { |
||||
|
|
||||
|
public: |
||||
|
/**
|
||||
|
* Constructeur d'iterateur. L'iterateur retourne permet |
||||
|
* d'acceder au premier element de la l'ensemble. |
||||
|
* |
||||
|
* @param e l'enemble sur lequel l'iterateur s'applique |
||||
|
*/ |
||||
|
Iterateur(const Ensemble<T> & e) : _ensemble(e) { |
||||
|
_noeudSuivant = e._liste; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Test la fin de l'ensemble itere |
||||
|
* |
||||
|
* @return true si il reste des element, false sinon |
||||
|
*/ |
||||
|
bool hasNext() const { |
||||
|
return _noeudSuivant != 0; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* @return l'element courant et passe au suivant |
||||
|
*/ |
||||
|
const T & next() { |
||||
|
const T & v = _noeudSuivant->getValeur(); |
||||
|
|
||||
|
_noeudSuivant = _noeudSuivant->getSuivant(); |
||||
|
|
||||
|
return v; |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
/**
|
||||
|
* l'enemble itere |
||||
|
*/ |
||||
|
const Ensemble<T> & _ensemble; |
||||
|
|
||||
|
/**
|
||||
|
* la position courante dans l'ensemble |
||||
|
*/ |
||||
|
Noeud * _noeudSuivant; |
||||
|
}; |
||||
|
|
||||
|
Noeud * _liste; |
||||
|
|
||||
|
|
||||
|
public: |
||||
|
|
||||
|
/**
|
||||
|
* Construit un ensemble vide. |
||||
|
*/ |
||||
|
Ensemble<T>() : _liste(0) { } |
||||
|
|
||||
|
/**
|
||||
|
* Construit un singleton. |
||||
|
*/ |
||||
|
Ensemble<T>(T x) { |
||||
|
_liste = new Noeud(x); |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Destructeur. |
||||
|
*/ |
||||
|
~Ensemble<T>() { |
||||
|
// delete 0 fonctionne !
|
||||
|
delete _liste; |
||||
|
_liste = 0; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Test si l'ensemble est vide. |
||||
|
* |
||||
|
* @return true si l'ensemble est vide, sinon false. |
||||
|
*/ |
||||
|
bool estVide() const { |
||||
|
return _liste == 0; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Envoie tous les elements dans un flot de sortie. |
||||
|
* |
||||
|
* @param out un flot de sortie. |
||||
|
* |
||||
|
* @return le flot de sortie donne en parametre. |
||||
|
*/ |
||||
|
std::ostream & flush(std::ostream & out) const { |
||||
|
Noeud * courant = _liste; |
||||
|
|
||||
|
out << "[ "; |
||||
|
|
||||
|
while (courant != 0) { |
||||
|
out << courant->getValeur() << " "; |
||||
|
courant = courant->getSuivant(); |
||||
|
} |
||||
|
|
||||
|
out << "]" << std::endl; |
||||
|
|
||||
|
return out; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Test l'appartenance d'un element a l'ensemble. |
||||
|
* |
||||
|
* @param x un double. |
||||
|
* |
||||
|
* @return true sie est dans l'ensemble, false sinon. |
||||
|
*/ |
||||
|
bool contient(const T & x) const { |
||||
|
Noeud * courant = _liste; |
||||
|
bool result = false; |
||||
|
|
||||
|
while (courant != 0) { |
||||
|
if (courant->getValeur() == x) { |
||||
|
result = true; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
courant = courant->getSuivant(); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Test l'inclusion dans un autre ensemble. |
||||
|
* |
||||
|
* @param e un ensemble |
||||
|
* |
||||
|
* @return true si "je" suis inclus dans e, false sinon. |
||||
|
*/ |
||||
|
bool estInclusDans(const Ensemble<T> & autre) const { |
||||
|
Noeud * courant = _liste; |
||||
|
bool result = true; |
||||
|
|
||||
|
while (courant != 0) { |
||||
|
if (!autre.contient(courant->getValeur())) { |
||||
|
result = false; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
courant = courant->getSuivant(); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Ajoute un "objet" a l'ensemble. |
||||
|
* |
||||
|
* @param x un element a ajouter a l'ensemble. |
||||
|
*/ |
||||
|
void ajoute(const T & x) { |
||||
|
if (!this->contient(x)) { |
||||
|
_liste = new Noeud(x, _liste); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Retire un element de l'esemble. |
||||
|
* |
||||
|
* @param e un element a retirer. |
||||
|
*/ |
||||
|
void retire(const T & e) { |
||||
|
_liste = _liste->retire(e); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Ajoute tous les elements dans un autre ensemble. |
||||
|
* |
||||
|
* @param e un ensemble |
||||
|
*/ |
||||
|
void ajouteDans(Ensemble<T> & e) const { |
||||
|
Noeud * courant = _liste; |
||||
|
|
||||
|
while (courant != 0) { |
||||
|
e.ajoute(courant->getValeur()); |
||||
|
|
||||
|
courant = courant->getSuivant(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Retire tous les elements dans un autre ensemble. |
||||
|
* Apres a.enleveDe(b), b vaut b - a (- ensembliste) |
||||
|
* |
||||
|
* @param e un ensemble dont il faut retirer des elements. |
||||
|
*/ |
||||
|
void retireDe(Ensemble<T> & e) const { |
||||
|
Noeud * courant = _liste; |
||||
|
|
||||
|
while (courant != 0) { |
||||
|
e.retire(courant->getValeur()); |
||||
|
courant = courant->getSuivant(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Constructeur par recopie. |
||||
|
* |
||||
|
* @param e un ensemble |
||||
|
*/ |
||||
|
Ensemble(const Ensemble<T> & e) { |
||||
|
if (!e.estVide()) { |
||||
|
this->_liste = new Noeud(*(e._liste)); |
||||
|
} else { |
||||
|
this->_liste = 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Operateur d'affectation d'un ensemble. |
||||
|
* |
||||
|
* @param e un ensemble |
||||
|
* |
||||
|
* @return une reference a moi-meme |
||||
|
*/ |
||||
|
Ensemble<T> & operator=(const Ensemble<T> & e) { |
||||
|
if (&e != this) { |
||||
|
delete this->_liste; |
||||
|
|
||||
|
// nous nous voyons ici dans l'obligation de recopier
|
||||
|
// le contenu du constructeur de recopie, ne pouvant
|
||||
|
// l'appeler directement.
|
||||
|
this->_liste = new Noeud(*(e._liste)); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Creation d'un singleton. |
||||
|
* |
||||
|
* @param x un element |
||||
|
* |
||||
|
* @return le singleton {x} |
||||
|
*/ |
||||
|
static Ensemble<T> singleton(T x) { |
||||
|
return Ensemble<T>(x); |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Creation d'un ensemble vide. |
||||
|
* |
||||
|
* @param x un double |
||||
|
* |
||||
|
* @return le singleton {x} |
||||
|
*/ |
||||
|
static Ensemble<T> ensembleVide() { |
||||
|
return Ensemble<T>(); |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Retourne un iterateur. |
||||
|
* |
||||
|
* @return un ipointeur sur un iterateur. |
||||
|
*/ |
||||
|
Iterateur * getIterateur() const { |
||||
|
return new Iterateur(*this); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Application d'une fonction a tous les elements d'un ensemble |
||||
|
* |
||||
|
* @param fct le foncteur |
||||
|
* @return copie le nouvel ensemble contenant les resultat en valeur de retour |
||||
|
*/ |
||||
|
Ensemble<T> appliquerAuxElements(Foncteur<T> & fct) const { |
||||
|
Ensemble<T> dest; |
||||
|
Iterateur * it = this->getIterateur(); |
||||
|
|
||||
|
while (it->hasNext()) { |
||||
|
dest.ajoute(fct(it->next())); |
||||
|
} |
||||
|
|
||||
|
delete it; |
||||
|
|
||||
|
return dest; |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/* Noeud * retireRec(Noeud * liste, T x);
|
||||
|
* |
||||
|
* NOTE : |
||||
|
* Cette fonction n'utilisant, ni variable d'instance, ni methode de cette |
||||
|
* classe, nous avon juge bon de deplacer cette fonction utilitaire dans la |
||||
|
* classe Noeud ou elle devient une methode d'instance a part entiere. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
}; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Operateur << pour les ensembles. |
||||
|
* |
||||
|
* @param out un flot de sortie. |
||||
|
* @param e un ensemble. |
||||
|
* |
||||
|
* @return le flot de sortie donne en argument. |
||||
|
*/ |
||||
|
template <typename T> |
||||
|
std::ostream & operator<<(std::ostream & out, const Ensemble<T> & e) { |
||||
|
return e.flush(out); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/*
|
||||
|
* Creation d'un singleton. |
||||
|
* |
||||
|
* Note : |
||||
|
* Cette fonction utilitaire nous semble plus a sa place |
||||
|
* en tant que méthode statique la classe Ensemble |
||||
|
* |
||||
|
* @param x un element |
||||
|
* |
||||
|
* @return le singleton {x} |
||||
|
*/ |
||||
|
//template<typename T> Ensemble<T> singleton(T x);
|
||||
|
|
||||
|
/**
|
||||
|
* Creation d'un ensemble vide. |
||||
|
* |
||||
|
* Note : |
||||
|
* Cette fonction utilitaire nous semble plus a sa place |
||||
|
* en tant que méthode statique la classe Ensemble |
||||
|
* |
||||
|
* @param x un double |
||||
|
* |
||||
|
* @return le singleton {x} |
||||
|
*/ |
||||
|
//template<typename T> Ensemble<T> ensembleVide();
|
||||
|
|
||||
|
/**
|
||||
|
* Teste l'egalite de deux ensembles. Cette fonction (et les suivantes ) |
||||
|
* serait aussi bien implemente en tant que methode membre, mais elle |
||||
|
* restera ici dans un but simplement didactique (syntaxe de la surcharge |
||||
|
* d'operateur hors classe et non acces a la partie privee afin d'utiliser |
||||
|
* les methodes publiques precedemment cites). On a egalite quand E1 |
||||
|
* inclus dans E2 et E2 inclus dans E1 |
||||
|
* |
||||
|
* @param a un ensemble. |
||||
|
* @param b un ensemble. |
||||
|
* |
||||
|
* @return true si a=b (i.e., a est inclus dans b et b est inclus dans a), |
||||
|
* sinon false. |
||||
|
*/ |
||||
|
template <typename T> |
||||
|
bool egale(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
return a.estInclusDans(b) && b.estInclusDans(a); |
||||
|
} |
||||
|
|
||||
|
template <typename T> |
||||
|
bool operator==(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
return egale(a, b); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/* ne voyons pas le sens de ces operateurs, dans le cas d'ensemble */ |
||||
|
|
||||
|
//template <typename T>
|
||||
|
//bool operator<(const Ensemble<T> & a, const Ensemble<T> & b) {}
|
||||
|
|
||||
|
//template <typename T>
|
||||
|
//bool operator>(const Ensemble<T> & a, const Ensemble<T> & b) {}
|
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Union de deux ensembles de doubles. |
||||
|
* |
||||
|
* @param a un ensemble de doubles. |
||||
|
* @param b un ensemble de doubles. |
||||
|
* |
||||
|
* @return a new Ensemble c = a union b. |
||||
|
*/ |
||||
|
template <typename T> |
||||
|
Ensemble<T> reunion(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
Ensemble<T> c(a); |
||||
|
b.ajouteDans(c); |
||||
|
return c; |
||||
|
} |
||||
|
|
||||
|
template <typename T> |
||||
|
Ensemble<T> operator+(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
return reunion(a, b); |
||||
|
} |
||||
|
|
||||
|
template <typename T> |
||||
|
Ensemble<T> operator|(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
return reunion(a, b); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Difference de deux ensembles. |
||||
|
* |
||||
|
* @param a un ensemble de doubles. |
||||
|
* @param b un ensemble de doubles. |
||||
|
* |
||||
|
* @return a new Ensemble a prive de b. |
||||
|
*/ |
||||
|
template <typename T> |
||||
|
Ensemble<T> difference(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
Ensemble<T> c(a); |
||||
|
b.retireDe(c); |
||||
|
return c; |
||||
|
} |
||||
|
|
||||
|
template <typename T> |
||||
|
Ensemble<T> operator-(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
return difference(a, b); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Difference symetrique entre deux ensembles. |
||||
|
* |
||||
|
* @param a un ensemble. |
||||
|
* @param b un ensemble. |
||||
|
* |
||||
|
* @return (a prive de b) union (b prive de a) |
||||
|
*/ |
||||
|
template <typename T> |
||||
|
Ensemble<T> diffSymetrique(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
return (a - b) + (b - a); |
||||
|
} |
||||
|
|
||||
|
template <typename T> |
||||
|
Ensemble<T> operator^(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
return diffSymetrique(a, b); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Intersection entre deux ensembles de doubles. |
||||
|
* |
||||
|
* @param a un ensemble de doubles. |
||||
|
* @param b un ensemble de doubles. |
||||
|
* |
||||
|
* @return l'intersection de a et b. |
||||
|
*/ |
||||
|
template <typename T> |
||||
|
Ensemble<T> intersection(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
return (a + b) - (a ^ b); |
||||
|
} |
||||
|
|
||||
|
template <typename T> |
||||
|
Ensemble<T> operator&(const Ensemble<T> & a, const Ensemble<T> & b) { |
||||
|
return intersection(a, b); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
#endif /* ENSEMBLE_H */ |
||||
|
|
||||
@ -0,0 +1,244 @@ |
|||||
|
/**
|
||||
|
* @file EnsembleDouble.h |
||||
|
* @author Sebastien Fourey |
||||
|
* @date Thu Nov 18 |
||||
|
* |
||||
|
* @brief Declaration de la classe EnsembleDouble. |
||||
|
* |
||||
|
*/ |
||||
|
#ifndef ENSEMBLEDOUBLE_H |
||||
|
#define ENSEMBLEDOUBLE_H |
||||
|
|
||||
|
#include <iostream> |
||||
|
#include <ostream> |
||||
|
using namespace std; |
||||
|
|
||||
|
/**
|
||||
|
* Classe permettant de representer un ensemble de |
||||
|
* double en utilisant uniquement la notion d'egalite entre |
||||
|
* double. Aucune relation d'ordre n'est utilisee (par exemple |
||||
|
* pour avoir un representation ordonnee en memoire qui accelererait |
||||
|
* les recherches).<br> |
||||
|
* Seul l'operateur == est utilise pour tester l'egalite de deux |
||||
|
* elements. |
||||
|
*/ |
||||
|
class EnsembleDouble { |
||||
|
|
||||
|
class Noeud { |
||||
|
double valeur; |
||||
|
Noeud * suivant; |
||||
|
public: |
||||
|
Noeud(double valeur, Noeud * suivant=0):valeur(valeur),suivant(suivant) { } |
||||
|
~Noeud() { delete suivant; } |
||||
|
double getValeur() { return valeur; } |
||||
|
Noeud * getSuivant() { return suivant; } |
||||
|
void setSuivant(Noeud * suivant) { Noeud::suivant = suivant; } |
||||
|
}; |
||||
|
|
||||
|
Noeud * liste; |
||||
|
|
||||
|
public: |
||||
|
|
||||
|
/**
|
||||
|
* Construit un ensemble vide. |
||||
|
*/ |
||||
|
EnsembleDouble():liste(0) { } |
||||
|
|
||||
|
/**
|
||||
|
* Construit un singleton. |
||||
|
*/ |
||||
|
EnsembleDouble(double x) { liste = new Noeud(x); } |
||||
|
|
||||
|
/**
|
||||
|
* Destructeur. |
||||
|
*/ |
||||
|
~EnsembleDouble(); |
||||
|
|
||||
|
/**
|
||||
|
* Test si l'ensemble est vide. |
||||
|
* |
||||
|
* @return true si l'ensemble est vide, sinon false. |
||||
|
*/ |
||||
|
bool estVide() { return liste == 0; } |
||||
|
|
||||
|
/**
|
||||
|
* Envoie tous les elements dans un flot de sortie. |
||||
|
* |
||||
|
* @param out un flot de sortie. |
||||
|
* |
||||
|
* @return le flot de sortie donne en parametre. |
||||
|
*/ |
||||
|
ostream & flush(ostream & out) const; |
||||
|
|
||||
|
/**
|
||||
|
* Test l'appartenance d'un element a l'ensemble. |
||||
|
* |
||||
|
* @param x un double. |
||||
|
* |
||||
|
* @return true sie est dans l'ensemble, false sinon. |
||||
|
*/ |
||||
|
bool contient(double x) const; |
||||
|
|
||||
|
/**
|
||||
|
* Test l'inclusion dans un autre ensemble. |
||||
|
* |
||||
|
* @param e un ensemble |
||||
|
* |
||||
|
* @return true si "je" suis inclus dans e, false sinon. |
||||
|
*/ |
||||
|
bool estInclusDans(const EnsembleDouble & autre) const; |
||||
|
|
||||
|
/**
|
||||
|
* Ajoute un "objet" a l'ensemble. |
||||
|
* |
||||
|
* @param e un double a ajouter à l'ensemble. |
||||
|
*/ |
||||
|
void ajoute(double x); |
||||
|
|
||||
|
/**
|
||||
|
* Retire un double de l'esemble. |
||||
|
* |
||||
|
* @param x un double a retirer. |
||||
|
*/ |
||||
|
void retire(double x); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Ajoute tous les elements dans un autre ensemble. |
||||
|
* |
||||
|
* @param e un ensemble |
||||
|
*/ |
||||
|
void ajouteDans(EnsembleDouble & e) const; |
||||
|
|
||||
|
/**
|
||||
|
* Retire tous les elements dans un autre ensemble. |
||||
|
* Apres a.enleveDe(b), b vaut b - a (- ensembliste) |
||||
|
* |
||||
|
* @param e un ensemble dont il faut retirer des elements. |
||||
|
*/ |
||||
|
void retireDe(EnsembleDouble & e) const; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Operateur d'affectation d'un ensemble. |
||||
|
* |
||||
|
* @param e un ensemble |
||||
|
* |
||||
|
* @return une reference a moi-meme |
||||
|
*/ |
||||
|
EnsembleDouble & operator=(const EnsembleDouble & e); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Constructeur par recopie. |
||||
|
* |
||||
|
* @param e un ensemble |
||||
|
*/ |
||||
|
EnsembleDouble(const EnsembleDouble & e); |
||||
|
|
||||
|
private: |
||||
|
|
||||
|
/**
|
||||
|
* Methode recursive de suppression d'un element dans |
||||
|
* une liste chainee. |
||||
|
* |
||||
|
* @param liste une liste. |
||||
|
* @param x un element. |
||||
|
* |
||||
|
* @return le liste sans l'element. |
||||
|
*/ |
||||
|
Noeud * retireRec(Noeud * liste, double x); |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
/**
|
||||
|
* Operateur << pour les enembles de double. |
||||
|
* |
||||
|
* @param out un flot de sortie. |
||||
|
* @param e un ensemble de doubles. |
||||
|
* |
||||
|
* @return le flot de sortie donne en argument. |
||||
|
*/ |
||||
|
ostream & operator<<(ostream & out, const EnsembleDouble & e); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Creation d'un singleton. |
||||
|
* |
||||
|
* @param x un double |
||||
|
* |
||||
|
* @return le singleton {x} |
||||
|
*/ |
||||
|
EnsembleDouble singleton(double x); |
||||
|
|
||||
|
/**
|
||||
|
* Creation d'un ensemble vide. |
||||
|
* |
||||
|
* @param x un double |
||||
|
* |
||||
|
* @return le singleton {x} |
||||
|
*/ |
||||
|
EnsembleDouble ensembleVide(); |
||||
|
|
||||
|
/**
|
||||
|
* Teste l'egalite de deux ensembles. |
||||
|
* |
||||
|
* @param a un ensemble. |
||||
|
* @param b un ensemble. |
||||
|
* |
||||
|
* @return true si a=b (i.e., a est inclus dans b et b est inclus dans a), |
||||
|
* sinon false. |
||||
|
*/ |
||||
|
bool egale(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
bool operator==(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
bool operator<(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
bool operator>(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Union de deux ensembles de doubles. |
||||
|
* |
||||
|
* @param a un ensemble de doubles. |
||||
|
* @param b un ensemble de doubles. |
||||
|
* |
||||
|
* @return a union b. |
||||
|
*/ |
||||
|
EnsembleDouble reunion(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
EnsembleDouble operator+(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
EnsembleDouble operator|(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
|
||||
|
/**
|
||||
|
* Difference de deux ensembles. |
||||
|
* |
||||
|
* @param a un ensemble de doubles. |
||||
|
* @param b un ensemble de doubles. |
||||
|
* |
||||
|
* @return a prive de b. |
||||
|
*/ |
||||
|
EnsembleDouble difference(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
EnsembleDouble operator-(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
|
||||
|
/**
|
||||
|
* Difference symetrique entre deux ensembles de doubles. |
||||
|
* |
||||
|
* @param a un ensemble de doubles. |
||||
|
* @param b un ensemble de doubles. |
||||
|
* |
||||
|
* @return (a prive de b) union (b prive de a) |
||||
|
*/ |
||||
|
EnsembleDouble diffSymetrique(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
EnsembleDouble operator^(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Intersection entre deux ensembles de doubles. |
||||
|
* |
||||
|
* @param a un ensemble de doubles. |
||||
|
* @param b un ensemble de doubles. |
||||
|
* |
||||
|
* @return l'intersection de a et b. |
||||
|
*/ |
||||
|
EnsembleDouble intersection(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
EnsembleDouble operator&(const EnsembleDouble & a, const EnsembleDouble & b); |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,137 @@ |
|||||
|
/**
|
||||
|
* @file essai_ensemble.cc |
||||
|
* @author Sebastien Fourey |
||||
|
* @date Thu Nov 18 20:38:47 2004 |
||||
|
* |
||||
|
* @brief Programme de test du modele de classe "Ensemble" |
||||
|
* defini dans Ensemble.hh |
||||
|
*/ |
||||
|
|
||||
|
/*
|
||||
|
* Ici, toute la definition du modele de classe "Ensemble" |
||||
|
* est dans un unique fichier .hh |
||||
|
* On ne fait plus de compilation separee. |
||||
|
* |
||||
|
*/ |
||||
|
|
||||
|
#include <ios> |
||||
|
#include <iostream> |
||||
|
#include <iomanip> |
||||
|
|
||||
|
#include "Ensemble.hh" |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
/**
|
||||
|
* Fonction principale du programme. |
||||
|
* |
||||
|
* @param argc le nombre d'arguments sur la ligne de commande. |
||||
|
* @param argv le tableau des arguments de la ligne de commande. |
||||
|
* |
||||
|
* @return 0 (SUCCESS) |
||||
|
*/ |
||||
|
int main(int argc, char * argv[]) { |
||||
|
|
||||
|
typedef Ensemble<double> EnsembleDouble; |
||||
|
EnsembleDouble e; |
||||
|
Ensemble<double> f; |
||||
|
Ensemble<double> g; |
||||
|
|
||||
|
for (int i = 1; i <= 10 ; i++) |
||||
|
e.ajoute(i); |
||||
|
|
||||
|
for (int i = 6; i <= 15 ; i++) |
||||
|
f.ajoute(i); |
||||
|
|
||||
|
for (int i = 11; i < 20 ; i++) |
||||
|
g.ajoute(i); |
||||
|
|
||||
|
cout << setiosflags(ios_base::boolalpha); // <iomanip>
|
||||
|
|
||||
|
// Alternative : cout.setf(ios_base::boolalpha); // <ios>
|
||||
|
|
||||
|
cout << e.contient(5) << endl; |
||||
|
|
||||
|
cout << f.contient(5) << endl; |
||||
|
|
||||
|
cout << g.contient(5) << endl; |
||||
|
|
||||
|
cout << "e = " << e << endl; |
||||
|
|
||||
|
cout << "f = " << f << endl; |
||||
|
|
||||
|
cout << "g = " << g << endl; |
||||
|
|
||||
|
/*
|
||||
|
e.retire(0); |
||||
|
cout << "e - 0 = " << e << endl; |
||||
|
e.retire(3); |
||||
|
cout << "e - 3 = " << e << endl; |
||||
|
e.retire(1); |
||||
|
cout << "e - 1 = " << e << endl; |
||||
|
e.retire(10); |
||||
|
cout << "e - 10 = " << e << endl; |
||||
|
e.retire(6); |
||||
|
cout << "e - 6 = " << e << endl; |
||||
|
*/ |
||||
|
|
||||
|
cout << " e U f = " << (e + f) << endl; |
||||
|
|
||||
|
cout << " e inter f = " << (e & f) << endl; |
||||
|
|
||||
|
cout << " e - f = " << (e - f) << endl; |
||||
|
|
||||
|
cout << " e inter g = " << (e & g) << endl; |
||||
|
|
||||
|
cout << " e diffSym f = " << (e ^ f) << endl; |
||||
|
|
||||
|
cout << " e diffSym g = " << (e ^ g) << endl; |
||||
|
|
||||
|
cout << " e - e = " << (e - e) << endl; |
||||
|
|
||||
|
cout << " e - {40.0} = " << (e - Ensemble<double>::singleton(40.0)) << endl; |
||||
|
|
||||
|
cout << " e U {40} U {50} = " << e + Ensemble<double>::singleton(40.0) + Ensemble<double>::singleton(50.0) << endl; |
||||
|
|
||||
|
cout << endl; |
||||
|
|
||||
|
cout << " e = " << e << endl; |
||||
|
|
||||
|
cout << " f = " << f << endl; |
||||
|
|
||||
|
cout << " (e U f) - f " << (e + f) - f << endl; |
||||
|
|
||||
|
cout << " (e U f) - f == e ? " << (((e + f) - f) == e) << endl; |
||||
|
|
||||
|
cout << " En effet, car e inter f = " << (e & f) << endl; |
||||
|
|
||||
|
cout << endl; |
||||
|
|
||||
|
cout << " e == e U {} ? " << ((e + Ensemble<double>()) == e) << endl; |
||||
|
|
||||
|
Foncteur<double> fct(3); |
||||
|
|
||||
|
cout << "e.appliquerAuxElements(Foncteur fct(3)) = " << e.appliquerAuxElements(fct) << endl; |
||||
|
|
||||
|
|
||||
|
// cout << " e - {5} < e ? " << ((e - Ensemble<double>(5.0)) < e) << endl;
|
||||
|
|
||||
|
Ensemble<bool> a, b; |
||||
|
|
||||
|
a.ajoute(true); |
||||
|
|
||||
|
b.ajoute(false); |
||||
|
|
||||
|
cout << endl; |
||||
|
|
||||
|
cout << " a = " << a << endl; |
||||
|
|
||||
|
cout << " b = " << b << endl; |
||||
|
|
||||
|
cout << " a + b = " << (a + b) << endl; |
||||
|
|
||||
|
cout << " a + b - {true} = " << ((a + b) - Ensemble<bool>::singleton(true)) << endl; |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,138 @@ |
|||||
|
/**
|
||||
|
* #(@)HollowMatrix.cpp ENSICAEN 2006 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Implements a hollow matrix. |
||||
|
*/ |
||||
|
|
||||
|
#include "HollowMatrix.h" |
||||
|
|
||||
|
#include <iomanip> |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
/*
|
||||
|
* @version 2006 |
||||
|
* |
||||
|
* @done - |
||||
|
* |
||||
|
* @todo - |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
double HollowMatrix::operator()(int r, int c) const { |
||||
|
pair<int, int> p = make_pair<int, int>(r, c); |
||||
|
double ret = 0; |
||||
|
|
||||
|
/*
|
||||
|
* Here, we do not use the operator [] because it inserts a default |
||||
|
* value in the map if the key cannot be found. |
||||
|
* |
||||
|
* The function find() does not modify the object. |
||||
|
*/ |
||||
|
ArrayOf2DPoints::const_iterator i = this->find(p); |
||||
|
|
||||
|
if (i != this->end()) { |
||||
|
ret = i->second; |
||||
|
} |
||||
|
|
||||
|
return ret; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void HollowMatrix::setValue(int r, int c, double v) { |
||||
|
pair<int, int> p = make_pair<int, int>(r, c); |
||||
|
|
||||
|
if (v != 0) { |
||||
|
(*this)[p] = v; |
||||
|
} else { |
||||
|
this->erase(p); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
int HollowMatrix::width(void) const { |
||||
|
int max = 0; |
||||
|
|
||||
|
for (ArrayOf2DPoints::const_iterator i = this->begin(); |
||||
|
i != this->end(); ++i) { |
||||
|
|
||||
|
/* i->first is the key, i->first.second is the col number */ |
||||
|
int col = i->first.second; |
||||
|
|
||||
|
if (col > max) { |
||||
|
max = col; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return max; |
||||
|
} |
||||
|
|
||||
|
int HollowMatrix::height(void) const { |
||||
|
int max = 0; |
||||
|
|
||||
|
for (ArrayOf2DPoints::const_iterator i = this->begin(); |
||||
|
i != this->end(); ++i) { |
||||
|
|
||||
|
/* i->first is the key, i->first.first is the row number */ |
||||
|
int row = i->first.first; |
||||
|
|
||||
|
if (row > max) { |
||||
|
max = row; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return max; |
||||
|
} |
||||
|
|
||||
|
ostream & operator<<(ostream & st, const HollowMatrix & m) { |
||||
|
int h = m.height(); |
||||
|
int w = m.width(); |
||||
|
|
||||
|
/* backup stream options */ |
||||
|
ios_base::fmtflags old_options = st.flags(); |
||||
|
|
||||
|
/* left alignment */ |
||||
|
st.setf(ios_base::left, ios_base::adjustfield); |
||||
|
|
||||
|
st << "["; |
||||
|
for (int r = 1; r <= h; r++) { |
||||
|
if (r == 1) { |
||||
|
st << "["; |
||||
|
} else { |
||||
|
st << " ["; |
||||
|
} |
||||
|
|
||||
|
for (int c = 1; c <= w; c++) { |
||||
|
/* the next field is 8 chars wide */ |
||||
|
st << setw(8); |
||||
|
|
||||
|
st << m(r, c); |
||||
|
} |
||||
|
|
||||
|
st << "]"; |
||||
|
|
||||
|
if (r != h) { |
||||
|
st << endl; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
st << "]" << endl; |
||||
|
|
||||
|
/* restore stream options */ |
||||
|
st.flags(old_options); |
||||
|
|
||||
|
return st; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,78 @@ |
|||||
|
/**
|
||||
|
* #(@)HollowMatrix.h ENSICAEN 2006 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* Defines a hollow matrix. |
||||
|
*/ |
||||
|
|
||||
|
#ifndef HOLLOW_MATRIX_H |
||||
|
#define HOLLOW_MATRIX_H |
||||
|
|
||||
|
#include <iostream> |
||||
|
#include <map> |
||||
|
#include <string> |
||||
|
|
||||
|
/*
|
||||
|
* @version 2006 |
||||
|
* |
||||
|
* @done - |
||||
|
* |
||||
|
* @todo - |
||||
|
*/ |
||||
|
|
||||
|
typedef std::map<std::pair<int, int>, double> ArrayOf2DPoints; |
||||
|
|
||||
|
class HollowMatrix : public ArrayOf2DPoints { |
||||
|
public: |
||||
|
/**
|
||||
|
* Returns the number at row r and col c. By default, all values in |
||||
|
* this matrix are zero. |
||||
|
* |
||||
|
* @param r the row number, starting at 1 |
||||
|
* @param c the col number, starting at 1 |
||||
|
* @return the value, 0 if not defined |
||||
|
*/ |
||||
|
double operator()(int r, int c) const; |
||||
|
|
||||
|
/**
|
||||
|
* Defines the number at row r and col c. If v is equal to zero, the |
||||
|
* number is removed from this matrix. |
||||
|
* |
||||
|
* @param r the row number, starting at 1 |
||||
|
* @param c the col number, starting at 1 |
||||
|
* @param v the value |
||||
|
*/ |
||||
|
void setValue(int r, int c, double v); |
||||
|
|
||||
|
/**
|
||||
|
* Returns the number of columns in this matrix. |
||||
|
* |
||||
|
* @return the number of columns in this matrix |
||||
|
*/ |
||||
|
int width(void) const; |
||||
|
|
||||
|
/**
|
||||
|
* Returns the number of rows in this matrix. |
||||
|
* |
||||
|
* @return the number of rows in this matrix |
||||
|
*/ |
||||
|
int height(void) const; |
||||
|
private: |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
std::ostream & operator<<(std::ostream & st, const HollowMatrix & m); |
||||
|
|
||||
|
#endif /* HOLLOW_MATRIX_H */ |
||||
|
|
||||
@ -0,0 +1,12 @@ |
|||||
|
CXXFLAGS := -Wall -g |
||||
|
LDFLAGS := -lstdc++ |
||||
|
|
||||
|
all: tp ex3 ex4 ex5 ex6 |
||||
|
|
||||
|
ex6: ex6.o HollowMatrix.o |
||||
|
|
||||
|
clean: |
||||
|
rm -f *.o tp ex3 ex4 ex5 ex6 |
||||
|
|
||||
|
.PHONY: all clean |
||||
|
|
||||
@ -0,0 +1,62 @@ |
|||||
|
/**
|
||||
|
* #(@)ex3.cpp ENSICAEN 2005 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* TP7 : Utilisation des conteneurs de la STL. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
// STL includes
|
||||
|
#include <iostream> |
||||
|
#include <fstream> |
||||
|
#include <set> |
||||
|
#include <string> |
||||
|
|
||||
|
#include <cstdlib> /* for exit() */ |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
int main(int argc, char ** argv) { |
||||
|
if (argc != 2) { |
||||
|
cout << "Usage : " << argv[0] << " <file>" << endl; |
||||
|
exit(1); |
||||
|
} |
||||
|
|
||||
|
ifstream st(argv[1]); |
||||
|
if (! st.is_open()) { |
||||
|
cout << "Erreur lors de l'ouverture du fichier !" << endl; |
||||
|
exit(2); |
||||
|
} |
||||
|
|
||||
|
set<char> s; |
||||
|
|
||||
|
char c = 0; |
||||
|
while (!st.eof()) { |
||||
|
st >> c; |
||||
|
s.insert(c); |
||||
|
} |
||||
|
|
||||
|
st.close(); |
||||
|
|
||||
|
cout << "Nombre de caracteres differents : " << s.size() << endl; |
||||
|
|
||||
|
for (set<char>::iterator i = s.begin(); i != s.end(); i++) { |
||||
|
cout << *i; |
||||
|
} |
||||
|
|
||||
|
cout << endl; |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,106 @@ |
|||||
|
/**
|
||||
|
* #(@)ex4.cpp ENSICAEN 2006 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* TP7 : Utilisation des conteneurs de la STL. |
||||
|
* TP7 - EX4 : Utilisation d'un tas pour trier. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
// STL includes
|
||||
|
#include <iostream> |
||||
|
#include <fstream> |
||||
|
#include <queue> |
||||
|
#include <vector> |
||||
|
#include <string> |
||||
|
|
||||
|
#include <cstdlib> /* for exit() */ |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
/**
|
||||
|
* Sorts the vector using a heap. |
||||
|
* |
||||
|
* @param v a vector |
||||
|
* @return a sorted copy of the vector |
||||
|
*/ |
||||
|
template<typename T, class Cmp> vector<T> trier(vector<T> & v) { |
||||
|
priority_queue<T, vector<T>, Cmp> pq; |
||||
|
vector<T> vs; |
||||
|
|
||||
|
for (typename vector<T>::iterator i = v.begin(); i != v.end(); i++) { |
||||
|
pq.push(*i); |
||||
|
} |
||||
|
|
||||
|
while (! pq.empty()) { |
||||
|
vs.push_back(pq.top()); |
||||
|
pq.pop(); |
||||
|
} |
||||
|
|
||||
|
return vs; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Fill a vector with 20 integers and sort it using a heap. |
||||
|
* |
||||
|
* Trace : |
||||
|
* Unsorted vector : 83 86 77 15 93 35 86 92 49 21 62 27 90 59 63 26 40 26 |
||||
|
* 72 36 |
||||
|
* |
||||
|
* Sorted vector - less<int> : 93 92 90 86 86 83 77 72 63 62 59 49 40 36 35 |
||||
|
* 27 26 26 21 15 |
||||
|
* |
||||
|
* Sorted vector - greater<int> : 15 21 26 26 27 35 36 40 49 59 62 63 72 77 |
||||
|
* 83 86 86 90 92 93 |
||||
|
* |
||||
|
* |
||||
|
* @param argc number of arguments |
||||
|
* @param argv arguments |
||||
|
* @return 0 |
||||
|
*/ |
||||
|
int main(int argc, char ** argv) { |
||||
|
vector<int> v; |
||||
|
|
||||
|
for (int i = 0; i < 20; i++) { |
||||
|
/* L'ordre est conservé */ |
||||
|
v.push_back(random() % 100); |
||||
|
} |
||||
|
|
||||
|
cout << "Unsorted vector : "; |
||||
|
for (vector<int>::iterator i = v.begin(); i != v.end(); i++) { |
||||
|
cout << *i << " "; |
||||
|
} |
||||
|
cout << endl; |
||||
|
|
||||
|
/* Remark : notice the space between the two ">" after
|
||||
|
* the function name */ |
||||
|
vector<int> vs = trier<int, less<int> >(v); |
||||
|
|
||||
|
cout << "Sorted vector - less<int> : "; |
||||
|
for (vector<int>::iterator i = vs.begin(); i != vs.end(); i++) { |
||||
|
cout << *i << " "; |
||||
|
} |
||||
|
cout << endl; |
||||
|
|
||||
|
vs = trier<int, greater<int> >(v); |
||||
|
|
||||
|
cout << "Sorted vector - greater<int> : "; |
||||
|
for (vector<int>::iterator i = vs.begin(); i != vs.end(); i++) { |
||||
|
cout << *i << " "; |
||||
|
} |
||||
|
cout << endl; |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,65 @@ |
|||||
|
/**
|
||||
|
* #(@)ex5.cpp ENSICAEN 2006 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* TP7 : Utilisation des conteneurs de la STL. |
||||
|
* TP7 - EX5 : Tableaux associatifs. |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
// STL includes
|
||||
|
#include <iostream> |
||||
|
#include <fstream> |
||||
|
#include <map> |
||||
|
#include <string> |
||||
|
|
||||
|
#include <cstdlib> /* for exit() */ |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
|
||||
|
/**
|
||||
|
* Tests the implementation of associative arrays. |
||||
|
* |
||||
|
* Trace : |
||||
|
* Liste des personnes : |
||||
|
* JCVD 45 |
||||
|
* Le chat 10 |
||||
|
* Nicolas 21 |
||||
|
* Thomas 21 |
||||
|
* |
||||
|
* We can notice that the keys are sorted. |
||||
|
* |
||||
|
* @param argc number of arguments |
||||
|
* @param argv arguments |
||||
|
* @return 0 |
||||
|
*/ |
||||
|
int main(int argc, char ** argv) { |
||||
|
map<string, int> age; |
||||
|
|
||||
|
age["Nicolas"] = 21; |
||||
|
age["Thomas"] = 21; |
||||
|
age["JCVD"] = 45; |
||||
|
age["Le chat"] = 10; |
||||
|
|
||||
|
cout << "Liste des personnes : " << endl; |
||||
|
for (map<string, int>::const_iterator i = age.begin(); i != age.end(); ++i) { |
||||
|
/* i->first is the key, i->second is the value */ |
||||
|
cout << i->first << '\t' << i->second << endl; |
||||
|
} |
||||
|
cout << endl; |
||||
|
|
||||
|
return 1; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,169 @@ |
|||||
|
/**
|
||||
|
* #(@)ex6.cpp ENSICAEN 2006 |
||||
|
* |
||||
|
* @author MASSE Nicolas (2005-Groupe3-LIMIN) <nicolas27.masse@laposte.net> |
||||
|
* @author LIMIN Thomas (2005-Groupe3-MASSE) <thomas.limin@laposte.net> |
||||
|
* |
||||
|
* ENSICAEN |
||||
|
* 6 Boulevard Marechal Juin |
||||
|
* F-14050 Caen Cedex |
||||
|
* |
||||
|
* Ce fichier est l'oeuvre d'eleves de l'ENSI de Caen. Il ne peut etre |
||||
|
* reproduit, utilise ou modifie sans l'avis express de ses auteurs. |
||||
|
*/ |
||||
|
|
||||
|
/**
|
||||
|
* TP7 : Utilisation des conteneurs de la STL. |
||||
|
* TP7 - EX6 : Matrice creuse à l'aide d'une map. |
||||
|
*/ |
||||
|
|
||||
|
/*
|
||||
|
* @version 2006 |
||||
|
* |
||||
|
* @done - |
||||
|
* |
||||
|
* @todo debug HollowMatrix.h |
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
// STL includes
|
||||
|
#include <iostream> |
||||
|
#include <iomanip> |
||||
|
#include <fstream> |
||||
|
#include <map> |
||||
|
#include <string> |
||||
|
|
||||
|
#include <cstdlib> /* for exit() */ |
||||
|
|
||||
|
|
||||
|
#include "HollowMatrix.h" |
||||
|
|
||||
|
using namespace std; |
||||
|
|
||||
|
/**
|
||||
|
* Prints the results of the comparison of the two pairs. Example : |
||||
|
* |
||||
|
* code : printPair(make_pair<int, int>(1, 10), |
||||
|
* make_pair<int, int>(2, 1), "<"); |
||||
|
* on screen : (1, 10) < (2, 1) = true |
||||
|
* |
||||
|
* @param p1 the first pair. |
||||
|
* @param p2 the second pair. |
||||
|
* @param op the operator (<, >, == or !=) |
||||
|
*/ |
||||
|
template<typename T1, typename T2> |
||||
|
void printPair(pair<T1, T2> p1, pair<T1, T2> p2, string op) { |
||||
|
cout << "(" << p1.first << ", " << p1.second << ") "; |
||||
|
cout << op; |
||||
|
cout << " (" << p2.first << ", " << p2.second << ") = "; |
||||
|
|
||||
|
if (op == "<") { |
||||
|
cout << (p1 < p2); |
||||
|
} else if (op == ">") { |
||||
|
cout << (p1 > p2); |
||||
|
} else if (op == "!=") { |
||||
|
cout << (p1 != p2); |
||||
|
} else if (op == "==") { |
||||
|
cout << (p1 == p2); |
||||
|
} else { |
||||
|
cout << "not true, not false"; |
||||
|
} |
||||
|
|
||||
|
cout << endl; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Tests the truth of the order relations on pairs. Results are printed |
||||
|
* on the screen. |
||||
|
*/ |
||||
|
void testPairs(void) { |
||||
|
/* true */ |
||||
|
printPair(make_pair<int, int>(1, 10), make_pair<int, int>(2, 1), "<"); |
||||
|
|
||||
|
/* true */ |
||||
|
printPair(make_pair<int, int>(0, 0), make_pair<int, int>(0, 10), "<"); |
||||
|
|
||||
|
/* false, equal */ |
||||
|
printPair(make_pair<int, int>(0, 0), make_pair<int, int>(0, 0), "<"); |
||||
|
|
||||
|
/* true */ |
||||
|
printPair(make_pair<int, double>(1, 8.5), |
||||
|
make_pair<int, double>(1, 9), "<"); |
||||
|
|
||||
|
/* true */ |
||||
|
printPair(make_pair<int, int>(0, 0), make_pair<int, int>(0, 1), "!="); |
||||
|
|
||||
|
/* false, equal */ |
||||
|
printPair(make_pair<int, int>(0, 5), make_pair<int, int>(0, 5), ">"); |
||||
|
|
||||
|
/* false, equal */ |
||||
|
printPair(make_pair<int, int>(0, 5), make_pair<int, int>(0, 5), "<"); |
||||
|
|
||||
|
/* true */ |
||||
|
printPair(make_pair<int, int>(0, 5), make_pair<int, int>(0, 5), "=="); |
||||
|
|
||||
|
/* false, "debrie" > "clouard" */ |
||||
|
printPair(make_pair<string, int>("debrie", 10), |
||||
|
make_pair<string, int>("clouard", 40), "<"); |
||||
|
|
||||
|
cout << endl; |
||||
|
} |
||||
|
|
||||
|
void testMatrix(void) { |
||||
|
HollowMatrix m; |
||||
|
|
||||
|
m.setValue(1, 1, 1); |
||||
|
m.setValue(2, 2, 1); |
||||
|
m.setValue(3, 3, 1); |
||||
|
m.setValue(4, 4, 1); |
||||
|
|
||||
|
m.setValue(2, 3, 23); |
||||
|
if (m(2 ,3) != 23 || m(3, 2) == 23) { |
||||
|
cout << "Erreur: " << __FILE__ << ":" << __LINE__ << endl; |
||||
|
} |
||||
|
|
||||
|
m.setValue(3, 4, -2.3); |
||||
|
m.setValue(2, 4, 1.23456789); |
||||
|
|
||||
|
cout << "check: " << 1 << 1.0 << 2 << -3 << 4 << endl; |
||||
|
cout << endl; |
||||
|
|
||||
|
/* original matrix */ |
||||
|
cout << m; |
||||
|
cout << endl; |
||||
|
|
||||
|
/* add 4 columns */ |
||||
|
m.setValue(1, 8, 1); |
||||
|
cout << m; |
||||
|
cout << endl; |
||||
|
|
||||
|
/* delete 4 columns */ |
||||
|
m.setValue(1, 8, 0); |
||||
|
cout << m; |
||||
|
cout << endl; |
||||
|
|
||||
|
/* We can modify the matrix using the functions of the map class */ |
||||
|
m[make_pair<int, int>(5, 5)] = 666; |
||||
|
cout << m; |
||||
|
cout << endl; |
||||
|
|
||||
|
cout << "check: " << 1 << 1.0 << 2 << -3 << 4 << endl; |
||||
|
} |
||||
|
|
||||
|
/**
|
||||
|
* Tests the order relations on pairs. Tests the implementation of the matrix. |
||||
|
* |
||||
|
* @param argc number of arguments |
||||
|
* @param argv arguments |
||||
|
* @return 0 |
||||
|
*/ |
||||
|
int main(int argc, char ** argv) { |
||||
|
/* Displays boolean as "true" or "false" */ |
||||
|
cout << setiosflags(ios_base::boolalpha); |
||||
|
|
||||
|
testPairs(); |
||||
|
testMatrix(); |
||||
|
|
||||
|
return 1; |
||||
|
} |
||||
|
|
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue