Skip to content

Commit a2aa4c7

Browse files
committed
v1.1
1 parent c145ecd commit a2aa4c7

File tree

10 files changed

+63
-88
lines changed

10 files changed

+63
-88
lines changed

bin/App.class

-1.04 KB
Binary file not shown.

bin/adherent.class

2 Bytes
Binary file not shown.

bin/mediatheque.class

-75 Bytes
Binary file not shown.

bin/oeuvre.class

0 Bytes
Binary file not shown.

bin/pret.class

2 Bytes
Binary file not shown.

src/App.java

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,37 @@
44
public class App extends JFrame {
55
private mediatheque M = new mediatheque(Constants.ADHERENTS_XML_FILEPATH, Constants.OEUVRES_XML_FILEPATH, Constants.PRETS_XML_FILEPATH);
66
public App() {
7-
//test01();
8-
//test02();
9-
//test03();
107
GUI();
118
}
129

13-
void test01() {
14-
mediatheque M = new mediatheque(Constants.ADHERENTS_XML_FILEPATH, Constants.OEUVRES_XML_FILEPATH, Constants.PRETS_XML_FILEPATH);
15-
M.addAdherent(new adherent(001, "ADRANE", "Akram", "Med V Goulmima", "akram.quark@gmail.com"));
16-
M.addAdherent(new adherent(002, "HARCHA", "Badr", "Med V Oujda", "badr.harcha@gmail.com"));
17-
adherent testAD1 = new adherent(003, "MOUGHIL", "Naoufal", "MED V Kenitra", "naoufal.moughil@gmail.com");
18-
M.addAdherent(testAD1);
19-
//M.deleteAdherent(testAD1);
20-
M.addOeuvre(new oeuvre(0000,"Jolie", "Nothing", "Ricardo", "William", 2020, "disponible"));
21-
oeuvre testOEUV1 = new oeuvre(0001,"Ikhan", "WOW", "Igoulmimen", "Aha", 2023, "disponible");
22-
M.addOeuvre(testOEUV1);
23-
//M.deleteOeuvre(testOEUV1);
24-
}
25-
26-
void test02() {
27-
M.OprintAll();
28-
M.OprintCat("Nothing");
29-
}
30-
31-
void test03() {
32-
M.emprunter(new pret("01/01/2023", 1, 0));
33-
M.emprunter(new pret("01/01/2023", 1, 0));
34-
}
35-
3610
void GUI() {
37-
setTitle("TP 4 in Java");
11+
setTitle("Library Management System");
3812
setSize(800, 600);
3913

4014
setLocationRelativeTo(null);
4115

4216
JPanel mainPanel = new JPanel(new BorderLayout());
4317

4418
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
45-
JLabel mediathequeLabel = new JLabel("Mediatheque");
19+
JLabel mediathequeLabel = new JLabel("Library Management System");
4620
mediathequeLabel.setForeground(Color.RED);
4721
mediathequeLabel.setFont(new Font("Arial", Font.BOLD, 50));
22+
Insets margin = new Insets(15, 0, 40, 0);
23+
topPanel.setBorder(BorderFactory.createEmptyBorder(margin.top, margin.left, margin.bottom, margin.right));
4824
topPanel.add(mediathequeLabel);
4925

5026
JPanel middlePanel = new JPanel(new GridLayout(1, 3));
5127

5228
JPanel oeuvresPanel = new JPanel(new BorderLayout());
53-
JLabel oeuvresLabel = new JLabel("Gestion des oeuvres", SwingConstants.CENTER);
29+
JLabel oeuvresLabel = new JLabel("Book Management", SwingConstants.CENTER);
5430
oeuvresLabel.setFont(new Font("Arial", Font.BOLD, 20));
5531
oeuvresPanel.add(oeuvresLabel, BorderLayout.NORTH);
5632
JPanel oeuvresButtonsPanel = new JPanel(new GridLayout(4, 1));
5733

58-
MultilineButton Button1 = new MultilineButton("Ajouter / Supprimer\nune oeuvre de la collection");
59-
MultilineButton Button2 = new MultilineButton("Rechercher une oeuvre");
60-
MultilineButton Button3 = new MultilineButton("Afficher tous les objets\nde la collection");
61-
MultilineButton Button4 = new MultilineButton("Afficher tous les objets\nd'une meme categorie");
34+
MultilineButton Button1 = new MultilineButton("Add/Remove a Book\nfrom the Collection");
35+
MultilineButton Button2 = new MultilineButton("Search for a Book");
36+
MultilineButton Button3 = new MultilineButton("Display All Books");
37+
MultilineButton Button4 = new MultilineButton("Display All Books\nin a Category");
6238

6339

6440
Button1.addActionListener(e -> M.eventB1());
@@ -74,14 +50,14 @@ void GUI() {
7450
middlePanel.add(oeuvresPanel);
7551

7652
JPanel adherentsPanel = new JPanel(new BorderLayout());
77-
JLabel adherentsLabel = new JLabel("Gestion des adherents", SwingConstants.CENTER);
53+
JLabel adherentsLabel = new JLabel("Members Management", SwingConstants.CENTER);
7854
adherentsLabel.setFont(new Font("Arial", Font.BOLD, 20));
7955
adherentsPanel.add(adherentsLabel, BorderLayout.NORTH);
8056
JPanel adherentsButtonsPanel = new JPanel(new GridLayout(3, 1));
8157

82-
MultilineButton Button5 = new MultilineButton("Ajouter un adherant");
83-
MultilineButton Button6 = new MultilineButton("Supprimer un adherant");
84-
MultilineButton Button7 = new MultilineButton("Afficher les adherants");
58+
MultilineButton Button5 = new MultilineButton("Add a member");
59+
MultilineButton Button6 = new MultilineButton("Remove a member");
60+
MultilineButton Button7 = new MultilineButton("Display members");
8561

8662
Button5.addActionListener(e -> M.eventB5());
8763
Button6.addActionListener(e -> M.eventB6());
@@ -94,13 +70,13 @@ void GUI() {
9470
middlePanel.add(adherentsPanel);
9571

9672
JPanel pretsPanel = new JPanel(new BorderLayout());
97-
JLabel pretsLabel = new JLabel("Gestion des prets", SwingConstants.CENTER);
73+
JLabel pretsLabel = new JLabel("Lending Management", SwingConstants.CENTER);
9874
pretsLabel.setFont(new Font("Arial", Font.BOLD, 20));
9975
pretsPanel.add(pretsLabel, BorderLayout.NORTH);
10076
JPanel pretsButtonsPanel = new JPanel(new GridLayout(2, 1));
10177

102-
MultilineButton Button8 = new MultilineButton("Emprunter une oeuvre");
103-
MultilineButton Button9 = new MultilineButton("Afficher les emprunts");
78+
MultilineButton Button8 = new MultilineButton("Borrow a Book");
79+
MultilineButton Button9 = new MultilineButton("Display Borrowed\nBooks");
10480

10581
Button8.addActionListener(e -> M.eventB8());
10682
Button9.addActionListener(e -> M.eventB9());
@@ -120,8 +96,7 @@ void GUI() {
12096
}
12197

12298
public static void main(String[] args) throws Exception {
123-
System.out.println("TP 4 in Java !");
124-
System.out.println("Hello World !");
99+
System.out.println("Library Management System Is Up And Running !");
125100
new App();
126101
}
127102
}

src/adherent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void setEmail(String email) {
5656
}
5757

5858
public String toString() {
59-
return "adherent [numero=" + numero + ", nom=" + nom + ", prenom=" + prenom + ", adresse=" + adresse
60-
+ ", email=" + email + "]";
59+
return "Member [ID=" + numero + ", LastName=" + nom + ", FirstName=" + prenom + ", Address=" + adresse
60+
+ ", Email=" + email + "]";
6161
}
6262
}

src/mediatheque.java

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public Boolean emprunter(pret pr) {
5454
OXML.setStatut(OXML.get(pr.getIdoeuvre()), "non disponible");
5555
return true;
5656
} else {
57-
System.out.println("Impossible d'emprunter !");
57+
System.out.println("Impossible to lend !");
5858
return false;
5959
}
6060
}
6161

6262
public void eventB1() {
63-
int choice = JOptionPane.showOptionDialog(null, "Choisissez une option :", "Ajouter ou Supprimer ?", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[]{"Ajouter une oeuvre", "Supprimer une oeuvre"}, null);
63+
int choice = JOptionPane.showOptionDialog(null, "Choose an option :", "Add or Remove?", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[]{"Add a book", "Delete a book"}, null);
6464
if (choice == 0) {
6565
JPanel dialogPanel = new JPanel(new GridLayout(0, 2));
6666
JTextField idField = new JTextField();
@@ -72,42 +72,42 @@ public void eventB1() {
7272
JTextField statusField = new JTextField();
7373
dialogPanel.add(new JLabel("ID :"));
7474
dialogPanel.add(idField);
75-
dialogPanel.add(new JLabel("Titre :"));
75+
dialogPanel.add(new JLabel("Title :"));
7676
dialogPanel.add(titleField);
77-
dialogPanel.add(new JLabel("Categorie:"));
77+
dialogPanel.add(new JLabel("Category :"));
7878
dialogPanel.add(categoryField);
79-
dialogPanel.add(new JLabel("Auteur :"));
79+
dialogPanel.add(new JLabel("Author :"));
8080
dialogPanel.add(authorField);
81-
dialogPanel.add(new JLabel("Editeur :"));
81+
dialogPanel.add(new JLabel("Publisher :"));
8282
dialogPanel.add(publisherField);
83-
dialogPanel.add(new JLabel("Annee de sortie :"));
83+
dialogPanel.add(new JLabel("Release date :"));
8484
dialogPanel.add(launchDateField);
85-
dialogPanel.add(new JLabel("Statut :"));
85+
dialogPanel.add(new JLabel("Status :"));
8686
dialogPanel.add(statusField);
8787

88-
int result = JOptionPane.showConfirmDialog(null, dialogPanel, "Ajouter une oeuvre", JOptionPane.OK_CANCEL_OPTION);
88+
int result = JOptionPane.showConfirmDialog(null, dialogPanel, "Add a book", JOptionPane.OK_CANCEL_OPTION);
8989
if (result == JOptionPane.OK_OPTION) {
9090
addOeuvre(new oeuvre(Integer.parseInt(idField.getText()), titleField.getText(), categoryField.getText(), authorField.getText(), publisherField.getText(), Integer.parseInt(launchDateField.getText()), statusField.getText()));
9191
System.out.println("Added !");
9292
}
9393
} else if (choice == 1) {
94-
int choice1 = JOptionPane.showOptionDialog(null, "Choisissez une option :", "Titre ou ID ?", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[]{"Selection par Titre", "Selection par ID"}, null);
94+
int choice1 = JOptionPane.showOptionDialog(null, "Choose an option :", "Title or ID ?", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[]{"Selection by Title", "Selection by ID"}, null);
9595
if (choice1 == 0 ) {
9696
JPanel panel = new JPanel();
97-
panel.add(new JLabel("Entrer le titre de l'oeuvre a supprimer :"));
97+
panel.add(new JLabel("Enter the title of the book to be deleted :"));
9898
JTextField textField = new JTextField(20);
9999
panel.add(textField);
100-
int result = JOptionPane.showConfirmDialog(null, panel, "Titre de l'oeuvre", JOptionPane.OK_CANCEL_OPTION);
100+
int result = JOptionPane.showConfirmDialog(null, panel, "Title of the book", JOptionPane.OK_CANCEL_OPTION);
101101
if (result == JOptionPane.OK_OPTION) {
102102
deleteOeuvre(new oeuvre(0, textField.getText(), null, null, null,0, null));
103103
System.out.println("Deleted ?!");
104104
}
105105
} else if (choice1 == 1) {
106106
JPanel panel = new JPanel();
107-
panel.add(new JLabel("Entrer l'ID de l'oeuvre a supprimer :"));
107+
panel.add(new JLabel("Enter the ID of the book to be deleted :"));
108108
JTextField textField = new JTextField(20);
109109
panel.add(textField);
110-
int result = JOptionPane.showConfirmDialog(null, panel, "ID de l'oeuvre", JOptionPane.OK_CANCEL_OPTION);
110+
int result = JOptionPane.showConfirmDialog(null, panel, "ID of the book", JOptionPane.OK_CANCEL_OPTION);
111111
if (result == JOptionPane.OK_OPTION) {
112112
deleteOeuvre(new oeuvre(Integer.parseInt(textField.getText()), null, null, null, null, 0, null));
113113
}
@@ -117,10 +117,10 @@ public void eventB1() {
117117

118118
public void eventB2() {
119119
JPanel panel = new JPanel();
120-
panel.add(new JLabel("Entrer l'ID ou bien le titre de l'oeuvre a chercher :"));
120+
panel.add(new JLabel("Enter the ID or title of the book to search for :"));
121121
JTextField textField = new JTextField(20);
122122
panel.add(textField);
123-
int result = JOptionPane.showConfirmDialog(null, panel, "ID/Titre de l'oeuvre", JOptionPane.OK_CANCEL_OPTION);
123+
int result = JOptionPane.showConfirmDialog(null, panel, "ID/Title of book", JOptionPane.OK_CANCEL_OPTION);
124124
if (result == JOptionPane.OK_OPTION) {
125125
oeuvre oeu = new oeuvre();
126126
try {
@@ -130,27 +130,27 @@ public void eventB2() {
130130
}
131131

132132
if (oeu != null) {
133-
String message = "ID :" + oeu.getId() + "\nCategorie: " + oeu.getCategorie() + "\nTitre: " + oeu.getTitre() + "\nEditeur: " + oeu.getEditeur() + "\nDate de sortie: " + oeu.getLaunchdate() + "\nStatut: " + oeu.getStatut();
133+
String message = "ID :" + oeu.getId() + "\nCategory: " + oeu.getCategorie() + "\nTitle: " + oeu.getTitre() + "\nPublisher: " + oeu.getEditeur() + "\nRelease date: " + oeu.getLaunchdate() + "\nStatus: " + oeu.getStatut();
134134
JOptionPane.showMessageDialog(null, message);
135135
} else {
136-
JOptionPane.showMessageDialog(null, "Introuvable", "Error", JOptionPane.ERROR_MESSAGE);
136+
JOptionPane.showMessageDialog(null, "Not Found !", "Error", JOptionPane.ERROR_MESSAGE);
137137
}
138138
}
139139
}
140140

141141
public void eventB34(String x) {
142142
if (!x.equals("*")) {
143143
JPanel panel = new JPanel();
144-
panel.add(new JLabel("Entrer la categorie :"));
144+
panel.add(new JLabel("Enter category :"));
145145
JTextField textField = new JTextField(20);
146146
panel.add(textField);
147-
int result = JOptionPane.showConfirmDialog(null, panel, "Categorie ?", JOptionPane.OK_CANCEL_OPTION);
147+
int result = JOptionPane.showConfirmDialog(null, panel, "Category ?", JOptionPane.OK_CANCEL_OPTION);
148148
if (result == JOptionPane.OK_OPTION) {
149149
x = textField.getText();
150150
}
151151
}
152152

153-
String[] columnNames = {"ID", "Titre", "Categorie", "Auteur", "Editeur", "Date de sortie", "Statut"};
153+
String[] columnNames = {"ID", "Title", "Category", "Author", "Publisher", "Release date", "Status"};
154154

155155
ArrayList<ArrayList<String>> data = OXML.print(x);
156156

@@ -172,7 +172,7 @@ public void eventB34(String x) {
172172
frame.pack();
173173
frame.setVisible(true);
174174
} else {
175-
JOptionPane.showMessageDialog(null, "Introuvable", "Error", JOptionPane.ERROR_MESSAGE);
175+
JOptionPane.showMessageDialog(null, "Not Found !", "Error", JOptionPane.ERROR_MESSAGE);
176176
}
177177
}
178178

@@ -183,49 +183,49 @@ public void eventB5() {
183183
JTextField prenom = new JTextField();
184184
JTextField adresse = new JTextField();
185185
JTextField email = new JTextField();
186-
dialogPanel.add(new JLabel("Numero d'adherent :"));
186+
dialogPanel.add(new JLabel("Member ID :"));
187187
dialogPanel.add(numeroAd);
188-
dialogPanel.add(new JLabel("Nom :"));
188+
dialogPanel.add(new JLabel("Last name :"));
189189
dialogPanel.add(nom);
190-
dialogPanel.add(new JLabel("Prenom :"));
190+
dialogPanel.add(new JLabel("First name :"));
191191
dialogPanel.add(prenom);
192-
dialogPanel.add(new JLabel("Adresse :"));
192+
dialogPanel.add(new JLabel("Address :"));
193193
dialogPanel.add(adresse);
194194
dialogPanel.add(new JLabel("E-mail :"));
195195
dialogPanel.add(email);
196196

197-
int result = JOptionPane.showConfirmDialog(null, dialogPanel, "Ajouter un adherent", JOptionPane.OK_CANCEL_OPTION);
197+
int result = JOptionPane.showConfirmDialog(null, dialogPanel, "Add a member", JOptionPane.OK_CANCEL_OPTION);
198198
if (result == JOptionPane.OK_OPTION) {
199199
addAdherent(new adherent(Integer.parseInt(numeroAd.getText()), nom.getText(), prenom.getText(), adresse.getText(), email.getText()));
200200
System.out.println("Added !");
201201
}
202202
}
203203

204204
public void eventB6() {
205-
int choice = JOptionPane.showOptionDialog(null, "Choisissez une option :", "ID ou E-mail ?", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[]{"Selection par ID", "Selection par E-mail"}, null);
205+
int choice = JOptionPane.showOptionDialog(null, "Choose an option :", "ID or E-mail ?", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[]{"Selection by ID", "Selection by E-mail"}, null);
206206
if (choice == 0 ) {
207207
JPanel panel = new JPanel();
208-
panel.add(new JLabel("Entrer l'ID de l'adherent a supprimer :"));
208+
panel.add(new JLabel("Enter the ID of the member to be deleted :"));
209209
JTextField textField = new JTextField(20);
210210
panel.add(textField);
211-
int result = JOptionPane.showConfirmDialog(null, panel, "ID de l'adherent", JOptionPane.OK_CANCEL_OPTION);
211+
int result = JOptionPane.showConfirmDialog(null, panel, "Member ID", JOptionPane.OK_CANCEL_OPTION);
212212
if (result == JOptionPane.OK_OPTION) {
213213
deleteAdherent(new adherent(Integer.parseInt(textField.getText()), null, null, null, null));
214214
}
215215
} else if (choice == 1) {
216216
JPanel panel = new JPanel();
217-
panel.add(new JLabel("Entrer l'e-mail de l'adherent a supprimer :"));
217+
panel.add(new JLabel("Enter the e-mail address of the member to be deleted :"));
218218
JTextField textField = new JTextField(20);
219219
panel.add(textField);
220-
int result = JOptionPane.showConfirmDialog(null, panel, "ID de l'oeuvre", JOptionPane.OK_CANCEL_OPTION);
220+
int result = JOptionPane.showConfirmDialog(null, panel, "Book ID", JOptionPane.OK_CANCEL_OPTION);
221221
if (result == JOptionPane.OK_OPTION) {
222222
deleteAdherent(new adherent(0, null, null, null, textField.getText()));
223223
}
224224
}
225225
}
226226

227227
public void eventB7() {
228-
String[] columnNames = {"ID", "Nom", "Prenom", "Adresse", "E-mail"};
228+
String[] columnNames = {"ID", "Last name", "First name", "Address", "E-mail"};
229229

230230
ArrayList<ArrayList<String>> data = AXML.print();
231231

@@ -247,7 +247,7 @@ public void eventB7() {
247247
frame.pack();
248248
frame.setVisible(true);
249249
} else {
250-
JOptionPane.showMessageDialog(null, "Introuvable", "Error", JOptionPane.ERROR_MESSAGE);
250+
JOptionPane.showMessageDialog(null, "Not Found !", "Error", JOptionPane.ERROR_MESSAGE);
251251
}
252252
}
253253

@@ -256,22 +256,22 @@ public void eventB8() {
256256
JTextField pretdate = new JTextField();
257257
JTextField idadherent = new JTextField();
258258
JTextField idoeuvre = new JTextField();
259-
dialogPanel.add(new JLabel("Date de prete :"));
259+
dialogPanel.add(new JLabel("Lending date :"));
260260
dialogPanel.add(pretdate);
261-
dialogPanel.add(new JLabel("ID d'adherent :"));
261+
dialogPanel.add(new JLabel("Member ID :"));
262262
dialogPanel.add(idadherent);
263-
dialogPanel.add(new JLabel("ID d'oeuvre :"));
263+
dialogPanel.add(new JLabel("Book ID :"));
264264
dialogPanel.add(idoeuvre);
265-
int result = JOptionPane.showConfirmDialog(null, dialogPanel, "Preter LOG", JOptionPane.OK_CANCEL_OPTION);
265+
int result = JOptionPane.showConfirmDialog(null, dialogPanel, "Lending Information", JOptionPane.OK_CANCEL_OPTION);
266266
if (result == JOptionPane.OK_OPTION) {
267267
if (!emprunter(new pret(pretdate.getText(), Integer.parseInt(idadherent.getText()), Integer.parseInt(idoeuvre.getText())))) {
268-
JOptionPane.showMessageDialog(null, "Impossible d'emprunter", "Error", JOptionPane.ERROR_MESSAGE);
268+
JOptionPane.showMessageDialog(null, "Impossible to lend", "Error", JOptionPane.ERROR_MESSAGE);
269269
}
270270
}
271271
}
272272

273273
public void eventB9() {
274-
String[] columnNames = {"Date de prete", "ID adherent", "ID oeuvre"};
274+
String[] columnNames = {"Lending date", "Member ID", "Book ID"};
275275

276276
ArrayList<ArrayList<String>> data = PXML.print();
277277

@@ -293,7 +293,7 @@ public void eventB9() {
293293
frame.pack();
294294
frame.setVisible(true);
295295
} else {
296-
JOptionPane.showMessageDialog(null, "Introuvable", "Error", JOptionPane.ERROR_MESSAGE);
296+
JOptionPane.showMessageDialog(null, "Not Found !", "Error", JOptionPane.ERROR_MESSAGE);
297297
}
298298
}
299299
}

0 commit comments

Comments
 (0)