Question: help my fix my code so it runs as a game import java.util.Scanner; / * * Game class to manage the core gameplay, including navigation

help my fix my code so it runs as a game
import java.util.Scanner;
/**
Game class to manage the core gameplay, including navigation between
scenes and resource management.
*/
public class game {
private boolean running;
private int water;
private int SoilHealth;
private int biodiversity;
private int pollution;
private int funds;
private String currentScene;
private boolean rarePlant;
private boolean pollutionReducer;
private boolean advancedIrrigationSystem;
/**
Constructor to initialize game state.
*/
public game(){
this.running = true;
this.water =100;
this.soilHealth =100;
this.biodiversity =100;
thisipollution =0;
this.funds =100;
this.rarePlant = false;
this.pollutionReducer = false;
this.advancedIrrigationSystem = false;
this.currentScene = "TitleScreen";
}
/**
Starts the game loop.
*/
public void start(){
Scanner scanner = new Scanner(System.in);
while (running){
switch (currentScene){
case "TitleScreen":
showTitleScreen();
break;
case "MainMenu":
showMainMenu();
break;
case "ResourceManagement":
showResourceManagement();
break;
case "EcosystemStatus":
showEcosystemStatus();
break;
case "ItemShop":
showItemShop();
break;
case "SpecialEvent":
handHeEvents();
break;
case "Victory":
ShowVictory();
return;
case "Defeat":
showDefeat();
return;
case "Exit":
exit();
return;
default:
System.Out.println("Unknown scene: "+ currentScene);
running = false;
return;
}
int choice = scanner.nextInt();
handleChoice(choice);
}
scanner.close();
}
private void exit(){
}
private void showVictory(){
}
private void showDefeat(){
}
/**
Displays the title screen with ASCII art.
*/
private void ShowTitleScreen(){
System.Out.println("-
");
System.Out.println("||//__|_\/_\
||/// L |||'
System.out.println("'/|||||||||
private void showMainMenu(){
System.out.println("Main Menu:");
System.out.println("1. Manage Resources");
||/||_|\1
I \V/ I__/
");
System.out.println("|.|||||||||||
1|1|1
)
\II '/I
||
");
System.out.println("||||___|
/\I
/
");
/|_|II_II
I_-
System.out. bar(println)(" bar(n//Welcome) to EcoQuest!!");
System.out.println("1. Start Game");
System.out.println("2. Exit");
System out.print("Enter your choice: ");
}
/**
Displays the main menu.
*/
System.out.printIn("2. Check Ecosystem Status");
System.out.println("3. Visit Item Shop");
System.out.println("4. Special Event");
Sxstem.out.println("5. Exit");
System.out.print("Enter your choice: ");
}
/**
Handles the user's choice at the main menu.
@param choice the user's menu choice
*/
private void handleChoice(int choice){
switch (currentScene){
case "TitleScreen":
if (choice ==1){
currentScene = "MainMenu";
} else if (choice ==2){
currentScene = "Exit";
} else {
System.Out.println("Invalid choice. Please try again.");
}
break;
case "MainMenu":
switch (choice){
case 1:
CurrentScene = "ResourceManagement";
break;
case 2:
currentScene = "EcosystemStatus";
break;
case 3:
currentScene = "ItemShop";
break;
case 4:
CurrentScene = "SpecialEvent";
break;
case 5:
currentScene = "Exit";
break;
default:
System.out.println("Invalid choice. Please try
again.");
}
break;
case "ResourceManagement":
manageResources(choice);
break;
case "ItemShop":
buyItems(choice);
break;
case "Ecos\stemStatus":
case "SpecialEvent":
CurrentScene = "MainMenu";
break;
}
CheckEndConditions();
}
/**
Displays the resource management scene.
*/
private void showResourceManagement(){
System.Out.println("Manage Resources:");
System.out.println("1. Add Water");
System.out.println("2. Improve Soil Health");
System.out.println("3. Promote Biodiversity");
System.out.println("4. Reduce Pollution");
System.out.println("5. Return to Main Menu");
System.out.print("Enter your choice: ");
}
/**
Manages resources based on the user's choice.
@param action the user's resource management choice
*/
private void manageResources(int action){
switch (action){
case 1:
water +=10;
System.Out.println("You added water. Water level increased by
10.");
break;
case 2:
SOilHealth +=10;
Sxstem.out.println("You improved soil health. Soil health
increased by 10.");
break;
case 3:
biodiversity +=10;
System,Out.println("You promoted biodiversity. Biodiversity
increased by 10.");
break;
case 4:
pollution -=10;
System,Out.println("You reduced pollution. Pollution
decreased by 10.");
break;
case 5:
currentScene = "MainMenu";
return;
default:
System.out.println("Invalid action. Please try again.");
}
System.out.println("Resource management complete.");
}
/**
Displays the ecosystem status.
*/
private void showEcosystemStatus(){
System.out.println("Ecosystem Status:");
Svstem, out orintln("Water: "+ water):
System.Out.printin("SOil Health: "+ sointealth);
System.out.println("Biodiversity: "+ biodiversity);
System.out.println("Pollution: "+ pollution);
System.out.println("Funds: "+ funds);
Sxstem.out.println("Press any key to return to the main menu.");
}
/**
Displays the item shop scene.
*/
private void showItemShop(){
System.out.println("Item Shop:");
System.out.println("1. Buy Rare Plant (Cost: 50)");
System.out.println("2. Buy Pollution Reducer (Cost: 70)");
System.out.println("3. Buy Advanced Irrigation System (Cost: 100)");
System.out.println("4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!