Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to write a simple text based game program, &need help with some of t

ID: 3612825 • Letter: I

Question

I am trying to write a simple text based game program, &need help with some of the basics. Specifically, I can declare only1 boolean for each object and only 1 int variable. I am havingtrouble getting started since the booleans change (for example,money might be true or false for a particular scenario depending onwhat you choose) and deciding what to do for the int. Pleasehelp! ----- The sample run should go something like this: You find money and meet and old man. What do you do? 1: Accept the coin, add it to your purse 2: Decline it, but give the old man all of your money Other: Ignore him and ride on Enter an integer: 1 Accept the coin, add it to your purse You lose the purse. You continue walking and find a dragon. What do you do? 1: Attack it. 2: Flee. etc. The actions for the first 2 scenarios are: 1: accept the coin, add it to you purse: go to 3,coin=true 2: decline the money, give it to the old man: goto 2,purse=false other: ride on: goto 2 1: attack the dragon with something other than the sword goto 4 if purse=true, goto 5 if purse=false 2: attack it with your sword etc. I am trying to write a simple text based game program, &need help with some of the basics. Specifically, I can declare only1 boolean for each object and only 1 int variable. I am havingtrouble getting started since the booleans change (for example,money might be true or false for a particular scenario depending onwhat you choose) and deciding what to do for the int. Pleasehelp! ----- The sample run should go something like this: You find money and meet and old man. What do you do? 1: Accept the coin, add it to your purse 2: Decline it, but give the old man all of your money Other: Ignore him and ride on Enter an integer: 1 Accept the coin, add it to your purse You lose the purse. You continue walking and find a dragon. What do you do? 1: Attack it. 2: Flee. etc. The actions for the first 2 scenarios are: 1: accept the coin, add it to you purse: go to 3,coin=true 2: decline the money, give it to the old man: goto 2,purse=false other: ride on: goto 2 1: attack the dragon with something other than the sword goto 4 if purse=true, goto 5 if purse=false 2: attack it with your sword etc.

Explanation / Answer

please rate - thanks this should get you started import java.util.Scanner; public class Maingame {     public static void main(String[] args) {    int state = 1,res;     boolean coin, purse = true, horse=true;     Scanner in=new Scanner(System.in);         while (true) {            if (state == 1) {                System.out.println(" Sir Hero, you have just left your castle gatein search of adventure You begin the journey with a horse, asword, and a purse of coins. Along the road you meet a decrepitold man who offers you a gold coin. What do you do? ");                System.out.println("1: accept the coin, add it to your purse");                System.out.println("2: decline the coin, give to old man all ofyour money");                System.out.println("other: ride on");              res=in.nextInt();         } } } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote