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 ;
this.soilHealth ;
this.biodiversity ;
thisipollution ;
this.funds ;
this.rarePlant false;
this.pollutionReducer false;
this.advancedIrrigationSystem false;
this.currentScene "TitleScreen";
Starts the game loop.
public void start
Scanner scanner new ScannerSystemin;
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.printlnUnknown scene: currentScene;
running false;
return;
int choice scanner.nextInt;
handleChoicechoice;
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.printlnMain Menu:";
System.out.println Manage Resources";
I V I
;
System.out.println
II I
;
System.out.println
I
;
IIII
I
System.out. barprintln barnWelcome to EcoQuest!!";
System.out.println Start Game";
System.out.println Exit";
System out.printEnter your choice: ;
Displays the main menu.
System.out.printIn Check Ecosystem Status";
System.out.println Visit Item Shop";
System.out.println Special Event";
Sxstem.out.println Exit";
System.out.printEnter your choice: ;
Handles the user's choice at the main menu.
@param choice the user's menu choice
private void handleChoiceint choice
switch currentScene
case "TitleScreen":
if choice
currentScene "MainMenu";
else if choice
currentScene "Exit";
else
System.Out.printlnInvalid choice. Please try again.";
break;
case "MainMenu":
switch choice
case :
CurrentScene "ResourceManagement";
break;
case :
currentScene "EcosystemStatus";
break;
case :
currentScene "ItemShop";
break;
case :
CurrentScene "SpecialEvent";
break;
case :
currentScene "Exit";
break;
default:
System.out.printlnInvalid choice. Please try
again.";
break;
case "ResourceManagement":
manageResourceschoice;
break;
case "ItemShop":
buyItemschoice;
break;
case "EcosstemStatus:
case "SpecialEvent":
CurrentScene "MainMenu";
break;
CheckEndConditions;
Displays the resource management scene.
private void showResourceManagement
System.Out.printlnManage Resources:";
System.out.println Add Water";
System.out.println Improve Soil Health";
System.out.println Promote Biodiversity";
System.out.println Reduce Pollution";
System.out.println Return to Main Menu";
System.out.printEnter your choice: ;
Manages resources based on the user's choice.
@param action the user's resource management choice
private void manageResourcesint action
switch action
case :
water ;
System.Out.printlnYou added water. Water level increased by
;
break;
case :
SOilHealth ;
Sxstem.out.printlnYou improved soil health. Soil health
increased by ;
break;
case :
biodiversity ;
System,Out.printlnYou promoted biodiversity. Biodiversity
increased by ;
break;
case :
pollution ;
System,Out.printlnYou reduced pollution. Pollution
decreased by ;
break;
case :
currentScene "MainMenu";
return;
default:
System.out.printlnInvalid action. Please try again.";
System.out.printlnResource management complete.";
Displays the ecosystem status.
private void showEcosystemStatus
System.out.printlnEcosystem Status:";
Svstem, out orintlnWater: water:
System.Out.printinSOil Health: sointealth;
System.out.printlnBiodiversity: biodiversity;
System.out.printlnPollution: pollution;
System.out.printlnFunds: funds;
Sxstem.out.printlnPress any key to return to the main menu.";
Displays the item shop scene.
private void showItemShop
System.out.printlnItem Shop:";
System.out.println Buy Rare Plant Cost: ;
System.out.println Buy Pollution Reducer Cost: ;
System.out.println Buy Advanced Irrigation System Cost: ;
System.out.println
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
