Skip to content

Commit

Permalink
Finished 2 xd
Browse files Browse the repository at this point in the history
  • Loading branch information
emilews committed Aug 19, 2019
1 parent 412d6f1 commit 53f0f4d
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 115 deletions.
35 changes: 25 additions & 10 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions core/src/countries/Countries.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

public class Countries {
//Variables for reading from file
private static BufferedReader bufferedReader = null;
private static BufferedWriter bufferedWriter = null;
private BufferedReader bufferedReader = null;
private BufferedWriter bufferedWriter = null;
//Variable for data holder, an ArrayList that uses the Country object only
private static ArrayList<Country> data = new ArrayList<>();
//Variable for csv file name
private static final String CSV_FILE_PATH = "Countries.csv";
private static final String CSV_FILE_PATH = "C:\\Users\\csipro\\Desktop\\Countries.csv";
//Instance of data holder
private static Countries instance;
//Private constructor
Expand Down Expand Up @@ -55,6 +55,7 @@ public static List<String> getAllContinents(){
for(int i = 0; i < data.size(); i++){
tempList.put(data.get(i).continent, i);
}
System.out.println(tempList.keySet());
conts.addAll(tempList.keySet());
return conts;
}
Expand Down Expand Up @@ -92,7 +93,7 @@ public List<String> getCountriesBySize(int size){
}

private void populate() throws Exception {
bufferedReader = new BufferedReader(new FileReader(new File(getClass().getClassLoader().getResource(CSV_FILE_PATH).getFile())));
bufferedReader = new BufferedReader(new FileReader(new File(CSV_FILE_PATH)));
String s = "";
int i = 0;
while((s = bufferedReader.readLine()) != null){
Expand All @@ -103,21 +104,17 @@ private void populate() throws Exception {
}
Country country = new Country(parts[0],parts[1],Integer.valueOf(parts[2]),parts[3]);
data.add(country);
System.out.println("Loaded one country");
}
i++;
}
}

public static void addNewCountry(String continent, String name, int size, String lang) throws IOException {
public static void addNewCountry(String continent, String name, int size, String lang) {
Country c = new Country(continent, name, size, lang);
data.add(c);
}






//Inner private class used to create an object for each country
private static class Country{
//Country variables
Expand Down
10 changes: 2 additions & 8 deletions desktop/src/controllers/AgregarController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@

public class AgregarController implements Initializable {
private Countries countries;
{
countries = Countries.getInstance();
}
static ObservableList<String> continents = FXCollections.observableArrayList();
{
continents.addAll(countries.getAllContinents());
}

@FXML
public TextField contName;
public TextField countName;
Expand All @@ -37,7 +31,7 @@ public class AgregarController implements Initializable {

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {

countries = Countries.getInstance();
}
public void addCountry() throws IOException {
int size = 0;
Expand Down
13 changes: 7 additions & 6 deletions desktop/src/controllers/ContinentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@

public class ContinentController implements Initializable {
private Countries countries;
{
countries = Countries.getInstance();
}
static ObservableList<String> continents = FXCollections.observableArrayList();
{
continents.addAll(countries.getAllContinents());
}

@FXML
public ChoiceBox<String> contChoice;
public ListView<String> byContinentList;


@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
countries = Countries.getInstance();
if(continents.isEmpty()){
continents.addAll(countries.getAllContinents());
contChoice.getItems().clear();
contChoice.getItems().addAll(continents);
}

}
public void populateListByContinent(){
Expand Down
4 changes: 1 addition & 3 deletions desktop/src/controllers/LangController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@

public class LangController implements Initializable {
private Countries countries;
{
countries = Countries.getInstance();
}
@FXML
public ListView<String> byLangList;
public ChoiceBox<String> langChoice;

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
countries = Countries.getInstance();
langChoice.getItems().clear();
langChoice.getItems().addAll(Countries.getAllLangs());
}
Expand Down
6 changes: 2 additions & 4 deletions desktop/src/controllers/SizeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@

public class SizeController implements Initializable {
private Countries countries;
{
countries = Countries.getInstance();
}

@FXML
public ListView<String> bySizeList;
public TextField sizeTextField;

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {

countries = Countries.getInstance();
}

public void populateListBySize(){
Expand Down
46 changes: 0 additions & 46 deletions desktop/src/controllers/TodoController.java

This file was deleted.

14 changes: 0 additions & 14 deletions desktop/src/views/Todo.fxml

This file was deleted.

Binary file modified out/production/core/countries/Countries$Country.class
Binary file not shown.
Binary file modified out/production/core/countries/Countries.class
Binary file not shown.
Binary file modified out/production/desktop/controllers/AgregarController.class
Binary file not shown.
Binary file modified out/production/desktop/controllers/ContinentController.class
Binary file not shown.
Binary file modified out/production/desktop/controllers/LangController.class
Binary file not shown.
Binary file modified out/production/desktop/controllers/SizeController.class
Binary file not shown.
Binary file not shown.
14 changes: 0 additions & 14 deletions out/production/desktop/views/Todo.fxml

This file was deleted.

0 comments on commit 53f0f4d

Please sign in to comment.