Skip to content

Commit

Permalink
fix: finish
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonGamerBot-QK committed Dec 20, 2024
1 parent f8050e6 commit 5b12f52
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
26 changes: 18 additions & 8 deletions projects/GeoGame/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ public void loadRegions() {
};
// use mustache notation to create an array for the image names
String[] regionImages = {
"africa.png",
"asia.png",
"americas.png",
"europe.png",
"northamerica.png",
"southamerica.png",
"oceania.png",
"antarctica.png",
"middleeast.png",
"south-america.png",
"asia-pacific.png",
"middle-east.png",
"central-america.png",
"north-america.png"
};
// Write a loop to create a region object for each region and store it in the array
for (String region : regionNames) {
Expand All @@ -105,6 +104,7 @@ public void showCountry() {
// Use the following code to create an new Image Icon and put it into the GUI
img = new ImageIcon("images/" + imagefile);
imageLabel.setIcon(img);
outputLabel.setText(country.toString());
}

/* showRegion() will show the image associated with the current region.
Expand All @@ -120,6 +120,7 @@ public void showRegion() {
img = new ImageIcon("images/" + imagefile);
// create a label to display image
imageLabel.setIcon(img);
outputLabel.setText(region.toString());
}

/* reviewButton should get the country/region at index from the corresponding array,
Expand Down Expand Up @@ -149,9 +150,18 @@ public void quizButtonClick() {
outputLabel.setText("");
// Get the country at index from countryArray
Country country = countryArray[cindex];
// print out a question about it like What country is this?
// print out a question about it like What country is this?
System.out.println("What country is this?");
// Get the user's answer using scan.nextLine()
String answer = scan.nextLine();
// check if it is equal to the country's data using its get methods
if (answer.equals(country.getName())) {
// print out correct
System.out.println("Correct");
} else {
// print out incorrect
System.out.println("Incorrect");
}
}

public void newButtonClick() {
Expand Down
3 changes: 3 additions & 0 deletions projects/GeoGame/Region.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ public String getImage() {
}
// Write a toString() method that returns a concatenated String of 3 of the instance
// variables in a sentence like "The region is ..."
public String toString() {
return "The region is " + name + " and the image is " + image;
}

}
2 changes: 1 addition & 1 deletion projects/GeoGame/countries-data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Japan,Tokyo,Japanese,japan.jpeg
Kenya,Nairobi,Swahili,kenya.jpeg
Mexico,Mexico City,Spanish,mexico.jpeg
United Kingdom,London,English,uk.jpeg
United States,Washington D.C.,English,us.jpeg
United States,Washington D.C.,English,usa.jpeg

0 comments on commit 5b12f52

Please sign in to comment.