Skip to content

Commit

Permalink
update BSTree
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyulie committed Nov 16, 2020
1 parent e0cea13 commit 0abda40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions BSTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public static void main(String[] args) {
String tmp;
StringTokenizer st;

BSTree<String, Cidade> mytree = new BSTree<String, Cidade>();
Cidade city;
BSTree<String, City> mytree = new BSTree<String, City>();
City city;

try {
FileReader in1 = new FileReader(args[0]);
Expand All @@ -227,11 +227,11 @@ public static void main(String[] args) {
tmp = br.readLine();
st = new StringTokenizer(tmp);

city = new Cidade(
city = new City(
st.nextToken(),
Integer.parseInt(st.nextToken())
);
mytree.put(city.get_nome(), city);
mytree.put(city.getName(), city);
}
br.close();
in1.close();
Expand All @@ -244,16 +244,12 @@ public static void main(String[] args) {
for (int j = 0; j < n; j ++) {
tmp = br.readLine();

//pos = rank(new Cidade(tmp, 0), whitelist);
//pos = rank(new City(tmp, 0), whitelist);
city = mytree.get(tmp);
if (city == null)
System.out.print("\n[Failed] " + tmp + " não foi encontrada.");
System.out.print("\n[Failed] " + tmp + " wasn't found.");
else {
System.out.print(
"\n[Ok]\t" + city.get_nome() +
" foi encontrada. Temperatura lá é " + city.get_temp() +
" F"
);
System.out.println("\n[Ok]\t" + city.toString());
}
}
br.close();
Expand Down
2 changes: 1 addition & 1 deletion City.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public int compareTo(City other) {

public String toString() {
String message = "The city " + name + " is measuring "
+ temperature + "°";
+ temperature + " F";
return message;
}

Expand Down

0 comments on commit 0abda40

Please sign in to comment.