je souhaiterais optimiser un code et faire le pseudo code correspondant svp aidez moi
import biputil.*;
import java.io.*;
/**
* @com.register ( clsid=72CBC516-6741-430F-859D-779EDFF3864B, typelib=FC184FEC-B0C1-48D3-BA51-B09ED77BD30A )
*/
public class xxxxx
{
public static void main (String[] args) throws Exception
{
boolean autreC = true ;
boolean autreF = true ;
int i = 0;
int j = 0;
int Montant =0;
String strDate = new String();
String strCodeRem = new String();
String strTotal = new String();
String strNClient = new String();
String strNFact = new String();
String strLine = new String ();
String strMontant = new String();
SequentialFile facture = new SequentialFile();
IndexedFile client = new IndexedFile();
try
{
do
{
System.out.print("Numero de Client ? :");
strNClient = getString();
client.open("fclient.txt");
strLine = client.read(strNClient);
if (client.InvalidKey == true)
{
System.err.println ("Err Client inconnu");
if (autreF = false );
}
else
{
System.out.println (strLine);
autreF = true;
j = j + 1;
}
client.close();
facture.open ("ffacture.txt",'w');
while (autreF == true)
{
if (client.InvalidKey == false)
do
{
System.out.print("Numero de Facture :");
strNFact = getString();
if (strNFact.length()!= 4)
{
System.err.println("Err Le Numero de facture doit etre compris entre 1000 et 9999.");
}
}while(strNFact.length()!= 4);
do
{
System.out.print("Date :");
strDate = VerifDate();
}while (strDate.equals (""));
do
{
System.out.print("Montant :");
strMontant = getString();
Integer nMontant = new Integer(strMontant);
Montant = nMontant.intValue();
if (Montant < 0)
{
System.out.println("Err Montant negatif");
}
}while(Montant < 0);
String strRemise = new String();
do
{
System.out.print("CodeRemise :");
strCodeRem = getString();
strRemise = getCode(strCodeRem);
}while (strRemise.equals (""));
Integer nRemise = new Integer(strRemise);
int TotalRem = nRemise.intValue();
strTotal = ((Montant-((Montant*TotalRem)/100)) + " euro(s)");
System.out.println("Montant calcule : " + strTotal);
System.out.print("Enregistrer la facture ? O / N :");
boolean bEnrFact = getBoolean();
{
facture.write (strNClient + ","+strNFact + "," + strDate.substring(0,10) + "," + strCodeRem + "," +
strTotal);
}
System.out.print("Autre facture ? O / N :");
autreF = getBoolean();
i = i + 1;
}if (client.InvalidKey == false)
System.out.print("Autre client ? O / N :");
autreC = getBoolean();
}
while (autreC == true);
System.out.print("Edition Bordereaux O / N :");
boolean bBord = getBoolean();
facture.close();
if (bBord == true)
{
facture.open ("ffacture.txt",'r') ;
System.out.println("N°Client"+"\t"+"N°"+"\t"+"Date"+"\t"+" CodeRemise"+"\t"+
"Montant Calcule");
System.out.println("");
String strControleur2 = "";
while (! facture.EndOfFile)
{
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
strLine = facture.read();
String strControleur1 = new String(facture.fieldOf(strLine,a));
if (strLine != null)
{
if (strControleur1.equals (strControleur2))
{
System.out.println("\t"+"\t"+ facture.fieldOf(strLine,b)+"\t"+facture.fieldOf(strLine,c)+"\t"+facture.fieldOf(strLine,d)+"\t"+"\t"+facture.fieldOf(strLine,e));
}
else
{
System.out.println(facture.fieldOf(strLine,a)+"\t"+"\t"+ facture.fieldOf(strLine,b)+"\t"+facture.fieldOf(strLine,c)+"\t"+facture.fieldOf(strLine,d)+"\t"+"\t"+facture.fieldOf(strLine,e));
}
System.out.println("");
strControleur2 = strControleur1;
}
}
facture.close();
System.out.println ("Total : "+ i + " factures saisie(s) pour "+
j + " client(s)");
System.out.println("");
System.out.println("***** Fin Programme ***** (ENTREE pour Sortir)");
System.in.read();
}
}
catch (IOException ioe)
{
System.out.println (ioe);
System.out.println ("Erreur de saisie clavier");
}
catch (NumberFormatException nfe)
{
System.out.println (nfe);
System.out.println ("La valeur doit etre un entier");
}
System.out.print("Fin de programme");
}
public static String getString()
throws IOException
{
byte bArray[] = new byte [20];
System.in.read(bArray);
String strSaisie = new String(bArray);
return strSaisie.substring(0, strSaisie.indexOf("\r\n"));
}
public static boolean getBoolean()
throws IOException, NumberFormatException
{
String strReponse = getString();
boolean bReponse = true;
if (strReponse.equals ("n") || strReponse.equals ("N"))
{
bReponse = false;
}
else
{
if (strReponse.equals ("o")|| strReponse.equals ("O"))
{
return bReponse;
}
else
{
System.err.println("Attention, repondez par O ou N ! Le programme continu");
return bReponse;
}
}
return bReponse;
}
public static String VerifDate ()
throws Exception
{
byte Tab[] = new byte[20];
System.in.read(Tab);
String strGetDate = new String (Tab);
String strControle = strGetDate.substring(0,strGetDate.indexOf("\r\n"));
if (strControle.length() != 10)
{
System.err.println("Err Date");
return strGetDate = "";
}
strControle = strGetDate.substring(0,strGetDate.indexOf("/"));
Integer nControle = new Integer(strControle);
int A = nControle.intValue();
int JMax = 0;
if (A < 2006)
{
System.err.println("Err Date");
return strGetDate = "";
}
strControle = strGetDate.substring(5,7);
nControle = new Integer(strControle);
int M = nControle.intValue();
strControle = strGetDate.substring(8,strGetDate.indexOf("\r\n"));
nControle = new Integer(strControle);
int J = nControle.intValue();
JMax = 0;
boolean VJ = false;
boolean VM = false;
if ((M >= 0) || (M <= 12))
{
VM = true;
if ((A % 400) == 0 || (((A % 100) != 0 && (A % 4)== 0) && M == 02))
{
JMax = 29;
}
else if (M == 2)
{
JMax = 28;
}
else if (M == 4 || M ==6 || M == 9 || M == 11)
{
JMax = 30;
}
else
{
JMax = 31;
}
}
if (J >= 1 && J <= JMax)
{
VJ = true;
}
if (VM != true || VJ != true)
{
System.out.println("Err Date");
return strGetDate = "";
}
return strGetDate;
}
public static String getCode(String strCodeRem)
throws Exception
{
if (strCodeRem.length() > 1)
{
System.out.println("Format Remise ");
}
String strCode = new String ();
if (strCodeRem.equals ("A")||strCodeRem.equals ("a"))
{
strCode = "5";
}
if (strCodeRem.equals ("C")||strCodeRem.equals ("c"))
{
strCode = "15";
}
if (strCodeRem.equals ("E")||strCodeRem.equals ("e"))
{
strCode = "30";
}
if (strCodeRem.equals ("K")||strCodeRem.equals ("k"))
{
strCode = "40";
}
if (strCodeRem.equals ("R")||strCodeRem.equals ("r"))
{
strCode = "55";
}
if (strCode.equals (""))
{
System.err.println("Err Remise");
}
return strCode;
}
}