📄 run.java
字号:
import java.io.*;
class run
{
public static final int nmaxclient=10;
public static final int nmaxcompte=10;
public static Personne Client[]=new Personne[nmaxclient];
public static int numclient=0;
public static int nbreclient=0;
public static int numcompte=0;
public static int nbrecompte=0;
public static Compte compte[]=new Compte[nmaxcompte];
public static void main(String argv[]) throws IOException
{
//test1();
FilesUtils.lireFichierClient();
FilesUtils.lireFichierCompte();
FilesUtils.lireFichierOperation();
if (argv.length==0)
textmenu();
else if(argv.length==1)
{
if(argv[0].equals("text"))
textmenu();
else if(argv[0].equals("graphic"))
// System.out.println("Pas encore programme !\n");
new graphicApp().show();
else
System.out.println("parametre incorrect\n"+argv[0]);
}
else System.out.println("Trop de parametre \n");
FilesUtils.enregistrerLesClient();
FilesUtils.enregistrerLesCompte();
FilesUtils.enregistrerLesoperation();
}
/*static void test1(){
Personne p=new Personne("Luo","wei",18);
//p.afficher();
p.setnumeross("00142252005");
p.setadresse("25,rue pasteur,75012 paris");
p.setemail("luowei@hotmail.com");
p.setportable("0608427091");
p.afficher('a');
}*/
static void textmenu()
{
System.out.println("Que souhaitez-vous faire ? \n");
System.out.println("1.Creer un nouveau client");
System.out.println("2.Creer un nouveau compte");
System.out.println("3.Afficher tous les clients");
System.out.println("4.Afficher un client");
System.out.println("5.Afficher un compte");
System.out.println("6.Editer un client");
System.out.println("7.Editer un compte");
System.out.println("8.Quitter\n\n");
System.out.print("Votre choix ? ");
int choix=Lire.i();
if(choix<=8&&choix>0)
{
switch(choix)
{
case 1:if(nbreclient==nmaxclient)
{
System.out.print("Impossible de creer un nouveau client");
return;
}
int age;
String nom,prenom,numeross,adress,email,telephone,portable;
System.out.print("Nom ? ");
nom=Lire.S();
System.out.print("prenom ? ");
prenom=Lire.S();
System.out.print("age ? ");
age=Lire.i();
System.out.print("numeross?");
numeross=Lire.S();
if (verifiernumeross(numeross)==0)
{
System.out.print("adress?");
adress=Lire.S();
System.out.print("email?");
email=Lire.S();
System.out.print("telephone?");
telephone=Lire.S();
System.out.print("portable?");
portable=Lire.S();
creernouveauclient(nom,prenom,age,numeross,adress,email,telephone,portable);
}
else
System.out.println("le numeross a ete existe");break;
case 2:
if(nbrecompte==nmaxcompte)
{
System.out.print("Impossible de creer un nouveau compte");
return;
}
else
{
String numero;
//String numeross;
char type;
int initsolde,t;
System.out.println("le numeross de client?");
numeross=Lire.S();
Personne proprietaire=rechercherclient(numeross);
if(proprietaire!=null)
{
System.out.println("numero de compt?");
numero=Lire.S();
if(verifiercompte(numero)==0)
{
System.out.println("type de compt?");
type=Lire.c();
System.out.println("initsolde de compt?");
initsolde=Lire.i();
creernouveaucompte(numero,type,initsolde,proprietaire);
}
else
System.out.println("le numero de compt a deja existe");
}
else
//System.out.println("erreur");
System.out.println("il n'y a pas de client comme ca!");
}
break;
case 3:affichertousclient();break;
case 4:afficherclient();break;
case 5:affichercompte();break;
case 6:editclient();break;
case 7:String i;
System.out.println("taper le numero de compte: ");
i=Lire.S();
Compte p=rechercherproprietair(i);
if(p!=null)
editcompte(p);
else
System.out.println("erreur numero");
break;
case 8: return;
}
}
else
System.out.println("erreur choix");
textmenu();
}
static void creernouveauclient(String nom,String prenom,int age,String numeross,String adress,String email,String telephone,String portable )
{
Client[numclient]=new Personne(nom,prenom,age,numeross,adress,email,telephone,portable);
nbreclient++;
numclient++;
}
static void creernouveaucompte(String numero,char type,int initsolde,Personne proprietaire)
{
compte[numcompte]=new Compte(numero,type,initsolde,proprietaire);
numcompte++;
nbrecompte++;
}
static Personne rechercherclient(String ns)
{
int i=0;
while(i<nbreclient&&Client[i].getnumeross().compareTo(ns)!=0)
i++;
if(i>nbreclient)
return null;
else
return Client[i];
}
static void affichercompte()
{
String i;
System.out.println("taper le numero de compte vous voulez afficher");
i=Lire.S();
int j=0;
while(j<nbrecompte)
{
if(i.compareTo(compte[j].getnumero())==0)
{
compte[j].afficher();
return;
}
else j++;
}
System.out.println("erreur");
}
static void afficherclient()
{
String n;
String p;
System.out.println("taper le nom de client vous voulez afficher");
n=Lire.S();
System.out.println("taper le prenom de client vous voulez afficher");
p=Lire.S();
int j=0;
while(j<nbreclient)
{
if(n.compareTo(Client[j].getnom())==0&&p.compareTo(Client[j].getprenom())==0)
{
Client[j].afficher();
return;
}
else
j++;
}
System.out.println("il n'y a pas de client vous voulez rechercher");
}
static void editclient()
{
int c;
int x=0;
System.out.println("quoi vous voulez edit?");
System.out.println("1.edit le nom et prenom");
//System.out.println("2.edit le prenom");
System.out.println("2.edit l'age");
System.out.println("3.quit");
System.out.println("");
System.out.print("voutre choix : ");
c=Lire.i();
if(c!=3)
{
x=rechercher();
if(x!=-1)
{switch(c)
{
case 1:editnom(Client[x]);
editprenom(Client[x]);break;
case 2:editage(Client[x]);break;
case 3:break;
}
}
editclient();
}
}
static int rechercher()
{
String n;
String p;
System.out.println("taper le nom de client vous voulez edit:");
n=Lire.S();
System.out.println("taper le prenom de client vous voulez edit:");
p=Lire.S();
int j=0;
while(j<nbreclient)
{
if(n.compareTo(Client[j].getnom())==0&&p.compareTo(Client[j].getprenom())==0)
{
return j;
}
else
j++;
}
System.out.println("pas trouve le nom et prenom");
return -1;
}
static void editnom(Personne E)
{
String n;
System.out.println("nouveau nom:");
n=Lire.S();
E.setnom(n);
}
static void editprenom(Personne E)
{
String p;
System.out.println("nouveau prenom:");
p=Lire.S();
E.setprenom(p);
}
static void editage(Personne E)
{
int a;
System.out.println("nouveau age:");
a=Lire.i();
E.setage(a);
}
static void editcompte(Compte p)
{
int choix;
System.out.println("quoi vous voulez edit?");
System.out.println("1.edit le numero de compte");
System.out.println("2.edit le type de compte");
System.out.println("3.edit le solde de compte");
System.out.println("4.quit");
System.out.println("");
System.out.print("voutre choix : ");
choix=Lire.i();
if(choix<=4&&choix>0)
{
switch(choix)
{
case 1:editnumero(p);break;
case 2:edittype(p);break;
case 3:editsolde(p);break;
case 4:return;
}
}
else
System.out.println("erreur choix");
editcompte(p);
}
static Compte rechercherproprietair(String i)
{
int j=0;
while(j<nbrecompte&&i.compareTo(compte[j].getnumero())!=0)
j++;
if(j>nbrecompte)
{
System.out.println("il n'y a pas de cette numero de compte");
return null;
}
else
return compte[j];
}
static void editnumero(Compte c)
{
String n;
System.out.println("nouveau numero:");
n=Lire.S();
c.setnumero(n);
}
static void edittype(Compte c)
{
char t;
System.out.println("nouveau type:");
t=Lire.c();
c.settype(t);
}
static void editsolde(Compte c)
{
c.setsolde();
System.out.println("taper le type de operation(r/d): ");
char t=Lire.c();
if(t!='r'&&t!='d')
System.out.println("erreur type");
else
{
System.out.println("taper le montant de operation:");
int m=Lire.i();
if(t=='r'&&m>c.getsolde())
System.out.println("il n'y a pas d'argent suiffit dans votre compte!");
else
{
System.out.println("taper le raison de operation: ");
String r=Lire.S();
System.out.println("taper le moyen de operation: ");
String my=Lire.S();
Operation op=new Operation(c.getnumero(),t,m,r,my);
//op.afficher();
c.ajouteroperation(op);
//if(t=='r')
//c.setsolde(c.getsolde()-op.getMontant());
//else if(t=='d')
//c.setsolde(c.getsolde()+op.getMontant());
}
}
}
static int verifiercompte(String s)
{
int n=0;
while(n<nbrecompte)
{
if(s.compareTo(compte[n].getnumero())==0)
{
//System.out.println("le numero de compt a deja existe");
return -1;
}
else n++;
}
return 0;
}
static int verifiernumeross(String s)
{
int n=0;
while(n<nbreclient)
{
if(s.compareTo(Client[n].getnumeross())==0)
{
//System.out.println("le numero de compt a deja existe");
return -1;
}
else n++;
}
return 0;
}
static void affichertousclient()
{
for(int i=0;i<nbreclient;i++)
Client[i].afficher();
System.out.println("");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -