-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestPortefeuille.java
More file actions
116 lines (84 loc) · 4.25 KB
/
Copy pathTestPortefeuille.java
File metadata and controls
116 lines (84 loc) · 4.25 KB
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Controleur;
import Modele.*;
import Vue.*;
import java.util.*;
/**
*
* @author Rim, Camille
*/
public class TestPortefeuille {
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
Portefeuille wallet = new Portefeuille();
Affichage display = new Affichage();
/*
Lire au clavier la valeur de clé d’un fonds et son montant ;
Appeler la méthode de recherche d’un fonds de la question 1.3 avec la clé saisie en paramètre ;
Si l’exception FondsInexistant est générée, instancier et ajouter le fonds à la HashMap des fonds ;
sinon générer l’exception Fonds
*/
System.out.println("======== RECHERCHE FONDS ========");
System.out.println("Entrez le nom du fonds :");
String keyF = sc.nextLine();
System.out.println("Entrez le montant du fonds :");
double amount = sc.nextDouble();
Fonds fonds = new Fonds(keyF, amount);
sc.nextLine();
wallet.ajoutHmapFonds(keyF, fonds);
/*
Lire au clavier la valeur de clé d’un instrument ;
Appeler la méthode de recherche d’un instrument de la question 1.4 avec la clé saisie en paramètre ;
Si l’exception InstrumentInexistant est générée, instancier l’instrument et l’ajouter à la HashMap des instruments.
Appeler la méthode de la question 1.2 pour ajouter le nouveau fonds dans la collection de l’instrument.
*/
System.out.println("======== RECHERCHE INSTRUMENT ========");
System.out.println("Entrez le nom de l'instrument :");
String keyI = sc.nextLine();
Instrument instru = new Instrument(keyI);
wallet.ajoutHmapInstrument(keyI, instru);
wallet.ajoutFondsInstrument(keyI, fonds);
/* Tester les méthodes de suppression de fonds et d'instrument */
System.out.println("========= SUPPRESSION FONDS =========");
System.out.println("Entrez le nom du fonds à supprimer :");
String keySuppF = sc.nextLine();
wallet.supprimerHmapFonds(keySuppF);
sc.nextLine() ;
System.out.println("======== SUPPRESSION INSTRUMENT ========");
System.out.println("Entrez le nom de l'instrument à supprimer :");
String keySuppI = sc.nextLine();
wallet.supprimerHmapInstrument(keySuppI);
sc.nextLine();
/* Testez votre tri en affichant dans la « Vue » les fonds d’un instrument, triés par montant. */
System.out.println("======== TRI INSTRUMENT ========");
System.out.println("Entrez la clé de l'instrument à trier :");
String keyInstruTri = sc.nextLine();
Instrument aTrier = new Instrument(keyInstruTri) ;
sc.nextLine();
System.out.println("Entrez le nombre de fonds à placer dans l'instrument :");
int nb = sc.nextInt();
for(int i=0 ; i < nb ; i++)
{
sc.nextLine();
System.out.println("Entrez le nom du fonds");
String keyList = sc.nextLine();
System.out.println("Entrez le montant du fonds");
double amountList = sc.nextDouble();
wallet.ajoutFondsInstrument(keyInstruTri, fonds);
}
display.afficherTriFondsInstrument(aTrier);
/* Tester les méthodes de la vue */
System.out.println("======== AFFICHER INSTRUMENT ========");
System.out.println(display.afficherInstrument(wallet.getHmapInstru()));
sc.nextLine() ;
System.out.println("======== AFFICHER POURCENTAGE FONDS ========");
System.out.println("Entrez la cle d'un fonds") ;
String keyPourcent = sc.nextLine();
display.afficherPourcentage(keyPourcent, wallet);
}
}