commit
cd74cf2a6b
771
tps/fonte/Game.c
771
tps/fonte/Game.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,19 +1,29 @@
|
|||
|
||||
/**
|
||||
|
||||
* @file Game.java
|
||||
* @author Pedro Costa
|
||||
* @version 0.1
|
||||
* @date 2022-09-25
|
||||
*
|
||||
* @author Pedro Lopes
|
||||
* @version 0.2
|
||||
* @date 2022-10-02
|
||||
* @copyright Copyright (c) 2022
|
||||
*/
|
||||
|
||||
**/
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Scanner;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------- //
|
||||
|
||||
public class Game {
|
||||
class Game {
|
||||
|
||||
static SimpleDateFormat default_dateFormat = new SimpleDateFormat("MMM/yyyy", Locale.ENGLISH);
|
||||
|
||||
|
|
@ -25,6 +35,7 @@ public class Game {
|
|||
private boolean windows, mac, linux;
|
||||
|
||||
public Game() {
|
||||
|
||||
this.name = this.owners = this.website = this.developers = null;
|
||||
this.languages = new ArrayList<String>();
|
||||
this.genres = new ArrayList<String>();
|
||||
|
|
@ -34,9 +45,8 @@ public class Game {
|
|||
this.windows = this.mac = this.linux = false;
|
||||
}
|
||||
|
||||
public Game(String name, String owners, String website, String developers, ArrayList<String> languages,
|
||||
ArrayList<String> genres, Date release_date, int app_id, int age, int dlcs, int upvotes, int avg_playtime,
|
||||
float price, boolean windows, boolean mac, boolean linux) {
|
||||
public Game(String name, String owners, String website, String developers, ArrayList<String> languages, ArrayList<String> genres, Date release_date, int app_id, int age, int dlcs, int upvotes, int avg_playtime, float price, boolean windows, boolean mac, boolean linux) {
|
||||
|
||||
this.name = name;
|
||||
this.owners = owners;
|
||||
this.website = website;
|
||||
|
|
@ -55,136 +65,44 @@ public class Game {
|
|||
this.linux = linux;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setOwners(String owners) {
|
||||
this.owners = owners;
|
||||
}
|
||||
|
||||
public void setWebsite(String website) {
|
||||
this.website = website;
|
||||
}
|
||||
|
||||
public void setDevelopers(String developers) {
|
||||
this.developers = developers;
|
||||
}
|
||||
|
||||
public void setLanguages(ArrayList<String> languages) {
|
||||
this.languages = languages;
|
||||
}
|
||||
|
||||
public void setGenres(ArrayList<String> genres) {
|
||||
this.genres = genres;
|
||||
}
|
||||
|
||||
public void setReleaseDate(Date release_date) {
|
||||
this.release_date = release_date;
|
||||
}
|
||||
|
||||
public void setAppId(int app_id) {
|
||||
this.app_id = app_id;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public void setDlcs(int dlcs) {
|
||||
this.dlcs = dlcs;
|
||||
}
|
||||
|
||||
public void setAvgPlaytime(int avg_playtime) {
|
||||
this.avg_playtime = avg_playtime;
|
||||
}
|
||||
|
||||
public void setPrice(float price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public void setUpvotes(float upvotes) {
|
||||
this.upvotes = upvotes;
|
||||
}
|
||||
|
||||
public void setWindows(boolean windows) {
|
||||
this.windows = windows;
|
||||
}
|
||||
|
||||
public void setMac(boolean mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public void setLinux(boolean linux) {
|
||||
this.linux = linux;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getOwners() {
|
||||
return this.owners;
|
||||
}
|
||||
|
||||
public String getWebsite() {
|
||||
return this.website;
|
||||
}
|
||||
|
||||
public String getDevelopers() {
|
||||
return this.developers;
|
||||
}
|
||||
|
||||
public ArrayList<String> getLanguages() {
|
||||
return this.languages;
|
||||
}
|
||||
|
||||
public ArrayList<String> getGenres() {
|
||||
return this.genres;
|
||||
}
|
||||
|
||||
public Date getReleaseDate() {
|
||||
return this.release_date;
|
||||
}
|
||||
|
||||
public int getAppId() {
|
||||
return this.app_id;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
}
|
||||
|
||||
public int getDlcs() {
|
||||
return this.dlcs;
|
||||
}
|
||||
|
||||
public int getAvgPlaytime() {
|
||||
return this.avg_playtime;
|
||||
}
|
||||
|
||||
public float getPrice() {
|
||||
return this.price;
|
||||
}
|
||||
|
||||
public float getUpvotes() {
|
||||
return this.upvotes;
|
||||
}
|
||||
|
||||
public boolean getWindows() {
|
||||
return this.windows;
|
||||
}
|
||||
|
||||
public boolean getMac() {
|
||||
return this.mac;
|
||||
}
|
||||
|
||||
public boolean getLinux() {
|
||||
return this.linux;
|
||||
}
|
||||
public void setName(String name) { this.name = name; }
|
||||
public void setOwners(String owners) { this.owners = owners; }
|
||||
public void setWebsite(String website) { this.website = website; }
|
||||
public void setDevelopers(String developers) { this.developers = developers; }
|
||||
public void setLanguages(ArrayList<String> languages) { this.languages = languages; }
|
||||
public void setGenres(ArrayList<String> genres) { this.genres = genres; }
|
||||
public void setReleaseDate(Date release_date) { this.release_date = release_date; }
|
||||
public void setAppId(int app_id) { this.app_id = app_id; }
|
||||
public void setAge(int age) { this.age = age; }
|
||||
public void setDlcs(int dlcs) { this.dlcs = dlcs; }
|
||||
public void setAvgPlaytime(int avg_playtime) { this.avg_playtime = avg_playtime; }
|
||||
public void setPrice(float price) { this.price = price; }
|
||||
public void setUpvotes(float upvotes) { this.upvotes = upvotes; }
|
||||
public void setWindows(boolean windows) { this.windows = windows; }
|
||||
public void setMac(boolean mac) { this.mac = mac; }
|
||||
public void setLinux(boolean linux) { this.linux = linux; }
|
||||
|
||||
public String getName() { return this.name; }
|
||||
public String getOwners() { return this.owners; }
|
||||
public String getWebsite() { return this.website; }
|
||||
public String getDevelopers() { return this.developers; }
|
||||
public ArrayList<String> getLanguages() { return this.languages; }
|
||||
public ArrayList<String> getGenres() { return this.genres; }
|
||||
public Date getReleaseDate() { return this.release_date; }
|
||||
public int getAppId() { return this.app_id; }
|
||||
public int getAge() { return this.age; }
|
||||
public int getDlcs() { return this.dlcs; }
|
||||
public int getAvgPlaytime() { return this.avg_playtime; }
|
||||
public float getPrice() { return this.price; }
|
||||
public float getUpvotes() { return this.upvotes; }
|
||||
public boolean getWindows() { return this.windows; }
|
||||
public boolean getMac() { return this.mac; }
|
||||
public boolean getLinux() { return this.linux; }
|
||||
|
||||
public Game clone() {
|
||||
|
||||
Game cloned = new Game();
|
||||
|
||||
cloned.name = this.name;
|
||||
cloned.owners = this.owners;
|
||||
cloned.website = this.website;
|
||||
|
|
@ -201,139 +119,192 @@ public class Game {
|
|||
cloned.windows = this.windows;
|
||||
cloned.mac = this.mac;
|
||||
cloned.linux = this.linux;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public void ler(String line) {
|
||||
public void read(String line) {
|
||||
|
||||
char c_search;
|
||||
int index = 0, atr_index = 0;
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "AppID"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.app_id = Integer.parseInt(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "Name"
|
||||
if (line.charAt(atr_index) != ',') {
|
||||
if (line.charAt(atr_index) == '\"') {
|
||||
if(line.charAt(atr_index) != ',') {
|
||||
|
||||
if(line.charAt(atr_index) == '\"') {
|
||||
|
||||
atr_index++;
|
||||
c_search = '\"';
|
||||
} else
|
||||
c_search = ',';
|
||||
while (true) {
|
||||
}
|
||||
else c_search = ',';
|
||||
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == c_search) {
|
||||
|
||||
if(line.charAt(index) == c_search) {
|
||||
|
||||
this.name = line.substring(atr_index, index);
|
||||
if (c_search == ',')
|
||||
index++;
|
||||
else if (c_search == '\"')
|
||||
index += 2;
|
||||
|
||||
if(c_search == ',') index++;
|
||||
else if(c_search == '\"') index += 2;
|
||||
|
||||
atr_index = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
atr_index = ++index;
|
||||
}
|
||||
else atr_index = ++index;
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find release date
|
||||
if (line.charAt(atr_index) != ',') {
|
||||
if(line.charAt(atr_index) != ',') {
|
||||
|
||||
SimpleDateFormat df;
|
||||
if (line.charAt(atr_index) == '\"') {
|
||||
|
||||
if(line.charAt(atr_index) == '\"') {
|
||||
|
||||
df = new SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH);
|
||||
|
||||
atr_index++;
|
||||
c_search = '\"';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
df = new SimpleDateFormat("MMM yyyy", Locale.ENGLISH);
|
||||
|
||||
c_search = ',';
|
||||
}
|
||||
while (true) {
|
||||
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == c_search) {
|
||||
try {
|
||||
this.release_date = df.parse(line.substring(atr_index, index));
|
||||
} catch (java.text.ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (c_search == ',')
|
||||
index++;
|
||||
else if (c_search == '\"')
|
||||
index += 2;
|
||||
|
||||
if(line.charAt(index) == c_search) {
|
||||
|
||||
try { this.release_date = df.parse(line.substring(atr_index, index)); }
|
||||
catch (java.text.ParseException e) { e.printStackTrace(); }
|
||||
|
||||
if(c_search == ',') index++;
|
||||
else if(c_search == '\"') index += 2;
|
||||
|
||||
atr_index = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
atr_index = ++index;
|
||||
}
|
||||
else atr_index = ++index;
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "Owners"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.owners = line.substring(atr_index, index);
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "Age"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.age = Integer.parseInt(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "Price"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.price = Float.parseFloat(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "DLCs"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.dlcs = Integer.parseInt(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "Languages"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ']') {
|
||||
|
||||
if(line.charAt(index) == ']') {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',')
|
||||
index++;
|
||||
else if (line.charAt(index) == '\"')
|
||||
index += 2;
|
||||
|
||||
if(line.charAt(index) == ',') index++;
|
||||
else if(line.charAt(index) == '\"') index += 2;
|
||||
|
||||
atr_index = index;
|
||||
break;
|
||||
} else if (line.charAt(index) == '\'') {
|
||||
}
|
||||
else if(line.charAt(index) == '\'') {
|
||||
|
||||
int wordStart = index + 1;
|
||||
while (true) {
|
||||
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == '\'') {
|
||||
|
||||
if(line.charAt(index) == '\'') {
|
||||
|
||||
this.languages.add(line.substring(wordStart, index));
|
||||
break;
|
||||
}
|
||||
|
|
@ -342,149 +313,265 @@ public class Game {
|
|||
}
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "Website"
|
||||
if (line.charAt(atr_index) != ',') {
|
||||
if (line.charAt(atr_index) == '\"') {
|
||||
if(line.charAt(atr_index) != ',') {
|
||||
|
||||
if(line.charAt(atr_index) == '\"') {
|
||||
|
||||
atr_index++;
|
||||
c_search = '\"';
|
||||
} else
|
||||
c_search = ',';
|
||||
}
|
||||
else c_search = ',';
|
||||
|
||||
while(true) {
|
||||
|
||||
while (true) {
|
||||
index++;
|
||||
if (line.charAt(index) == c_search) {
|
||||
|
||||
if(line.charAt(index) == c_search) {
|
||||
|
||||
this.website = line.substring(atr_index, index);
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
atr_index = ++index;
|
||||
}
|
||||
else atr_index = ++index;
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
|
||||
// Find "Windows"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.windows = Boolean.parseBoolean(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find "Mac"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.mac = Boolean.parseBoolean(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find "Linux"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.linux = Boolean.parseBoolean(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "Upvotes"
|
||||
int positives, negatives;
|
||||
while (true) {
|
||||
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
positives = Integer.parseInt(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
negatives = Integer.parseInt(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.upvotes = (float) (positives * 100) / (float) (positives + negatives);
|
||||
|
||||
this.upvotes = (float)(positives * 100) / (float)(positives + negatives);
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "AVG Playtime"
|
||||
while (true) {
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.avg_playtime = Integer.parseInt(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
// Find "Developers"
|
||||
if (line.charAt(atr_index) != ',') {
|
||||
if (line.charAt(atr_index) == '\"') {
|
||||
if(line.charAt(atr_index) != ',') {
|
||||
|
||||
if(line.charAt(atr_index) == '\"') {
|
||||
|
||||
atr_index++;
|
||||
c_search = '\"';
|
||||
} else
|
||||
c_search = ',';
|
||||
while (true) {
|
||||
}
|
||||
else c_search = ',';
|
||||
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == c_search) {
|
||||
|
||||
if(line.charAt(index) == c_search) {
|
||||
|
||||
this.developers = line.substring(atr_index, index);
|
||||
|
||||
atr_index = ++index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
atr_index = ++index;
|
||||
}
|
||||
else atr_index = ++index;
|
||||
|
||||
// ---------------------------------- //
|
||||
|
||||
|
||||
// Find "Genres"
|
||||
if (index < line.length() - 1) {
|
||||
if (line.charAt(index) == ',')
|
||||
atr_index = ++index;
|
||||
if (line.charAt(atr_index) == '\"') {
|
||||
if(index < line.length() - 1) {
|
||||
|
||||
if(line.charAt(index) == ',') atr_index = ++index;
|
||||
if(line.charAt(atr_index) == '\"') {
|
||||
|
||||
atr_index++;
|
||||
while (true) {
|
||||
|
||||
while(true) {
|
||||
|
||||
index++;
|
||||
if (line.charAt(index) == ',') {
|
||||
|
||||
if(line.charAt(index) == ',') {
|
||||
|
||||
this.genres.add(line.substring(atr_index, index));
|
||||
|
||||
atr_index = ++index;
|
||||
} else if (line.charAt(index) == '\"') {
|
||||
}
|
||||
else if(line.charAt(index) == '\"') {
|
||||
|
||||
this.genres.add(line.substring(atr_index, line.length() - 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
this.genres.add(line.substring(atr_index, line.length()));
|
||||
}
|
||||
else this.genres.add(line.substring(atr_index, line.length()));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------- //
|
||||
}
|
||||
|
||||
public void imprimir() {
|
||||
public void print() {
|
||||
|
||||
String avg_pt = null;
|
||||
if (this.avg_playtime == 0)
|
||||
avg_pt = "null ";
|
||||
else if (this.avg_playtime < 60)
|
||||
avg_pt = this.avg_playtime + "m ";
|
||||
|
||||
if(this.avg_playtime == 0) avg_pt = "null ";
|
||||
else if(this.avg_playtime < 60) avg_pt = this.avg_playtime + "m ";
|
||||
else {
|
||||
if (this.avg_playtime % 60 == 0)
|
||||
avg_pt = this.avg_playtime / 60 + "h ";
|
||||
else
|
||||
avg_pt = (this.avg_playtime / 60) + "h " + (this.avg_playtime % 60) + "m ";
|
||||
|
||||
if(this.avg_playtime % 60 == 0) avg_pt = this.avg_playtime / 60 + "h ";
|
||||
else avg_pt = (this.avg_playtime / 60) + "h " + (this.avg_playtime % 60) + "m ";
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat("##");
|
||||
System.out.println(this.app_id + " " + this.name + " " + default_dateFormat.format(this.release_date) + " "
|
||||
+ this.owners + " " + this.age + " " + String.format("%.2f", this.price) + " " + this.dlcs + " "
|
||||
+ this.languages + " " + this.website + " " + this.windows + " " + this.mac + " " + this.linux + " "
|
||||
+ (Float.isNaN(this.upvotes) ? "0.0% " : df.format(this.upvotes) + "% ") + avg_pt + this.developers
|
||||
+ " " + this.genres);
|
||||
|
||||
System.out.println(this.app_id + " " + this.name + " " + default_dateFormat.format(this.release_date) + " " + this.owners + " " + this.age + " " + String.format(Locale.ENGLISH, "%.2f", this.price) + " " + this.dlcs + " " + this.languages + " " + this.website + " " + this.windows + " " + this.mac + " " + this.linux + " " + (Float.isNaN(this.upvotes) ? "0% " : df.format(this.upvotes) + "% ") + avg_pt + this.developers + " " + this.genres);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------- //
|
||||
|
||||
public static boolean isFim(String line) { return line.compareTo("FIM") == 0; }
|
||||
|
||||
// -------------------------------------------------------------------------------------- //
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
ArrayList<Game> games = new ArrayList<Game>();
|
||||
|
||||
// ------------------------------------------------------------------------------ //
|
||||
|
||||
try {
|
||||
|
||||
// Read CSV file
|
||||
String basefile = "/tmp/games.csv";
|
||||
|
||||
FileInputStream fstream = new FileInputStream(basefile);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
|
||||
|
||||
// ------------------------------------ //
|
||||
|
||||
// Explode CSV file reading games
|
||||
String line;
|
||||
|
||||
while((line = br.readLine()) != null) {
|
||||
|
||||
Game game = new Game();
|
||||
|
||||
game.read(line);
|
||||
games.add(game);
|
||||
}
|
||||
|
||||
// Close CSV file
|
||||
fstream.close();
|
||||
}
|
||||
catch(IOException e) { e.printStackTrace(); }
|
||||
|
||||
// ---------------------------------------------------------------------------------------------- //
|
||||
|
||||
// Read .in file
|
||||
Scanner scr = new Scanner(System.in);
|
||||
String line = scr.nextLine();
|
||||
|
||||
while(true) {
|
||||
|
||||
if(isFim(line)) break;
|
||||
|
||||
int app_id = Integer.parseInt(line);
|
||||
|
||||
// Search game with .in id
|
||||
for(Game game : games) {
|
||||
|
||||
if(game.getAppId() == app_id) game.print();
|
||||
}
|
||||
|
||||
line = scr.nextLine();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------- //
|
||||
|
||||
scr.close();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------- //
|
||||
}
|
||||
Loading…
Reference in New Issue