1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
import java.util.ArrayList;
import java.util.Scanner;
public class main {
public static void main(String[] args) {
//-----------------------------------------------------------------------------Déclaration des variables
ArrayList<Client> listeClients = new ArrayList<Client>();
ArrayList<Medicament> listeMedicaments = new ArrayList<Medicament>();
Scanner ss = new Scanner(System.in);
Scanner si = new Scanner(System.in);
Scanner sd = new Scanner(System.in);
Scanner sb = new Scanner(System.in);
double age;
String nom = "";
String commune ="";
double tarif = 0;
boolean restart = true;
boolean tf;
boolean restartMed = true;
boolean tfMed;
boolean tfRevoirMed;
//---------------------------------------------------------------------- Demander les différents médicaments disponibles
System.out.println("Vous allez maintenant être invités à introduire les différents médicaments disponibles dans la pharmacie.");
while (restartMed == true)
{
System.out.println("Nom du medicament?");
String nextMedName = ss.nextLine();
System.out.println("Prix du médicament?");
double nextMedPrice = sd.nextDouble();
Medicament addMed = new Medicament(nextMedName, nextMedPrice);
listeMedicaments.add(addMed);
System.out.println("Voulez vous introduire un autre médicament ?(true/false)");
tfMed = sb.nextBoolean();
if(tfMed == true)
{
restartMed = true;
}
else if(tfMed ==false)
{
restartMed = false;
System.out.println("Voulez-vous revoir les médicaments encodés?(true/false)");
tfRevoirMed = sb.nextBoolean();
if (tfRevoirMed == true)
{
int iRevoirMed = 0;
while (iRevoirMed<listeMedicaments.size())
{
System.out.print(listeMedicaments.get(iRevoirMed).getNomMedicament()+", ");
System.out.println(listeMedicaments.get(iRevoirMed).getPrixMedicament()+" euros.");
iRevoirMed = iRevoirMed+1;
}
}
else if(tfRevoirMed == false);
{
//on ne fait rien.
}
}
}
//----------------------------------------------------------------------On demande les différents clients.
System.out.println("Vous allez maintenant être invité à encoder les diférents clients.");
while (restart==true)
{
System.out.println("Age du client?");
age = sd.nextDouble();
System.out.println("Nom du client?");
nom = ss.nextLine();
System.out.println("Commune du client?");
commune = ss.nextLine();
System.out.println("Tarif client?");
tarif = sd.nextDouble();
Client addClient = new Client(age, nom, commune, tarif);
listeClients.add(addClient);
addClient.setAgeClient(age);
System.out.println("Introduire un autre client?(true/false)");
tf = sb.nextBoolean();
if (tf == false)
{
restart = false;
}
}
//------------------------------------------------------------------------ On veut revoir les clients ?
System.out.println("Souhaitez vous revoir un client en particulier?(true/false)");
boolean revoirClients = sb.nextBoolean();
boolean revoirTousClients;
boolean revoirTarif;
int iFocus = 0;
int iAll=0;
if (revoirClients == true)
{
System.out.println("Quel est le numéro du client que vous souhaitez revoir? (En commençant à 0)");
System.out.println("Pour rappel vous avez enrengistré "+listeClients.size()+" client(s).");
iFocus = si.nextInt();
Client focus = (Client) listeClients.get(iFocus);
printClient(focus);
System.out.println("Voulez-vous voir le vrai tarif du client?(true/false)");
revoirTarif = sb.nextBoolean();
if (revoirTarif == true)
{
int iClientNumber = iFocus;
listeClients.get(iClientNumber).realTarif(listeClients.get(iClientNumber));
}
else if(revoirTarif == false)
{
//On ne fait rien.
}
}
else if (revoirClients == false)
{
System.out.println("Souhaitez vous revoir tous les clients?(true/false)");
revoirTousClients = sb.nextBoolean();
if (revoirTousClients == true)
{
while(iAll < listeClients.size())
{
Client allTemp = (Client) listeClients.get(iAll);
printClient(allTemp);
iAll = iAll+1;
}
boolean revoirTarifAll;
System.out.println("Voulez-vous revoir le tarif de tous vos clients?(true/false)");
revoirTarifAll = sb.nextBoolean();
if (revoirTarifAll == true)
{
int iRevoirTarifAll = 0;
while(iRevoirTarifAll<listeClients.size())
{
listeClients.get(iRevoirTarifAll).realTarif(listeClients.get(iRevoirTarifAll));
{
}
}}
else if(revoirTarifAll == false)
{
}
}
else if(revoirTousClients==false)
{
System.out.println("Au revoir !");
}
}
//------------------------------------------------------------------------
//-----------------------------------------------------------------------------
}
public static void printClient(Client client)
{
double age = client.getAgeClient();
System.out.println("Monsieur/madame "+client.getNomClient()+", originaire de la commune de "+client.getCommuneClient()+" et agé(e) de "+age+" ans, nous doit "+client.getTarifClient()+" euros.");
}
} |