//----------------------------------------------------------------------------- // corrige10.txt // repartir du corrigé table du TD 9 // on met simplement dans des fonctions le corrige table du TD 9 //----------------------------------------------------------------------------- // Ex2. class Compte static double taux int numero int solde int salaire constructeur basique void afficherTaux // comme TD 9, Ex. 5 void saisirTaux // comme TD 9, Ex. 5 void afficher(Compte c) print(c.numero, c.solde, c.salaire, taux*c.salaire) Compte creer(String[] args, int i) return new Compte(string2int(args[3*i+1]), string2int(args[3*i+2]), string2int(args[3*i+3])); class Ex/main Compte.saisirTaux(args) Compte c1 = Compte.creer(args, 0) Compte c2 = Compte.creer(args, 1) Compte.afficherTaux() Compte.afficher(c1) Compte.afficher(c2) //----------------------------------------------------------------------------- // Ex3. // exactement comme Compte, sauf qu'on saisit ne saisit pas le taux, // ce qui change un peu les indices de args sur la ligne de commande class Client String nom String ville int compte constructeur basique void afficher(Client c) print(c.nom, c.ville, c.compte) Client creer(String[] args, int i) return new Client(args[3*i], args[3*i+1], string2int(args[3*i+2])) class Ex3/main Client c1 = Client.creer(args, 0) Client c2 = Client.creer(args, 1) Client.afficher(c1) Client.afficher(c2) //----------------------------------------------------------------------------- // Ex4. // on met ensemble Ex2 et Ex3 : copier-coller, sauf la saisie sur la // ligne de commande qui change un peu class Compte // tout pareil que Ex2, sauf indices de args dans creer creer : new Compte(args[5*i+3], args[5*i+4], args[5*i+5]) class Client // tout pareil que Ex2, sauf indices de args dans creer creer : new Client(args[5*i+1], args[5*i+2], args[5*i+3]) class Ex4/main saisirTaux creer client 0 creer compte 0 creer client 1 creer compte 1 afficherTaux afficher client1 afficher compte1 afficher client2 afficher compte2 //-----------------------------------------------------------------------------