Question: Hello: I have the code for a text adventure game. I was looking for improvements on my code and was wondering how I could include
Hello: I have the code for a text adventure game. I was looking for improvements on my code and was wondering how I could include classes to make it easier to manage:
package pkgfinal.project;
import java.util.Random;
import java.util.Scanner;
public class FinalProject
public static void mainString args
Scanner in new ScannerSystemin;
Random rand new Random;
Requirement Array
String enemies "Psycho", "Skag", "Bruiser", "Bandit", "Rakk" ;
Requirement: Values and Variables
Requirement: Proper casing
Requirement: Methods
int maxEnemyHealth ;
int maxEnemyDamage ;
int health ;
int attackDamage ;
int numHealthPotion ;
int healthPotHealAmount ;
int healthPotDropChance ;
boolean running true;
System.out.printlnWelcome to the Borderlands, Vault Hunter!";
GAME:
Requirement: Loops
while running
System.out.println;
int enemyHealth rand.nextIntmaxEnemyHealth;
String enemy enemiesrandnextIntenemieslength;
System.out.printlnt# enemy appeared! #
;
Requirement: Loops
while enemyHealth
System.out.printlntYour HP: health;
System.out.printlnt enemy s HP: enemyHealth;
System.out.println
tWhat would you like to do;
System.out.printlnt Shoot";
System.out.printlnt Use health Syringe";
System.out.printlnt Flee!";
Requirement: Selections
String input innextLine;
if inputequals
int damageDealt rand.nextIntattackDamage;
int damageTaken rand.nextIntmaxEnemyDamage;
enemyHealth damageDealt;
health damageTaken;
System.out.printlnt You hit the" enemy "for" damageDealt "damage.";
System.out.printlnt You were hit for:" damageTaken;
Requirement: Selections
if health
System.out.printlnt You cannot continue the fight, Vault Hunter";
break;
else if inputequals
if numHealthPotion
health healthPotHealAmount;
numHealthPotion;
System.out.printlnt You took a health syringe, healing for healthPotHealAmount
t You now have" health HP
t You have numHealthPotion "Health syringe's left.
;
else
System.out.printlnt You have no health syringe's left. Shoot enemies for a chance of health!";
else if inputequals
System.out.printlntYou ran away from the fight!";
continue GAME;
else
System.out.printlntInvalid Command!";
if health
System.out.printlnYou fight for your life, weak from combat.";
break;
System.out.println;
System.out.println# enemy "was killed! #;
System.out.println# You have" health HP left.";
if randnextInt healthPotDropChance
numHealthPotion;
System.out.println# The enemy "dropped a health syringe! # ;
System.out.println# You now have numHealthPotion health syringes # ;
System.out.println;
System.out.printlnWhat action will you take?";
System.out.printlnContinue the fight?";
System.out.printlnLeave the fight";
String input innextLine;
Requirement: Loops
while input.equals && input.equals
System.out.printlnInvalid command!";
input innextLine;
if inputequals
System.out.printlnYou continue on with your fight!";
else if inputequals
System.out.printlnYou leave Pandora Successful.";
break;
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
