This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParseArtigos.java
42 lines (38 loc) · 1.55 KB
/
ParseArtigos.java
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
import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class ParseArtigos {
public static Map<String, Artigo> get(GestãoVintage.TipoArtigoColecao tipo) {
Map<String, Artigo> artigos = new HashMap<>();
try {
String file_path = "";
if (tipo.equals(GestãoVintage.TipoArtigoColecao.marketplace)) file_path = "input/marketplace.txt";
else file_path = "input/vendidos.txt";
File input = new File(file_path);
Scanner reader = new Scanner(input);
while (reader.hasNextLine()) {
String line = reader.nextLine();
String[] parse = line.split(";");
if (parse[0].equalsIgnoreCase("TShirt")) {
TShirt temp = ParseTShirt.parse(parse);
artigos.put(temp.getCod(), temp);
}
else if (parse[0].equalsIgnoreCase("Mala")) {
Mala temp = ParseMala.parse(parse);
artigos.put(temp.getCod(), temp);
}
else if (parse[0].equalsIgnoreCase("Sapatilha")) {
Sapatilha temp = ParseSapatilha.parse(parse);
artigos.put(temp.getCod(), temp);
}
}
reader.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred opening the file.");
e.printStackTrace();
}
return artigos;
}
}