Sample Run miller.cs: a.out Sir Hero, you have just left your castle gate in sea
ID: 3529846 • Letter: S
Question
Sample Run miller.cs: a.out Sir Hero, you have just left your castle gate in search of adventure. You begin the journey with a horse, a sword, and a purse of coins. Along the road you meet a decrepit old man who offers you a gold coin. What do you do? 1: Accept the coin, add it to your purse 2: Decline the coin, but give the generous old man all of your money Other: Ignore the man and ride on Enter an integer: 2 Decline the coin, but give the generous old man all of your money You have lost the purse. A mile past the old man a wandering grue menaces you with its fearsome claws. Grue are well known to be immune to the cut of a sword. What do you do? 1: Attack the grue with your something other than your sword 2: Attack the grue with your sword 3: Ride past the grue other: Turn back to your castle Enter an integer: 3 You ride past the grue. The grue leaps after you, taking down your noble steed from behind. You sneak away while it eats your horse. You have lost the horse. Escaping the fearsome grue, you finally have the good fortune to encounter a proper opponent, a dragon, which you defeat with your mighty sword. Its head would make a wondrous trophy hanging in your hall, but the treasure it hordes would also be most welcome. Which is more important? 1: treasure is most important other: trophy is most important Enter an integer: 7 You think the trophy is more important. While impressed with your dragon-head trophy, the serfs at your castle are disappointed that not only did you fail to bring back any treasure; you lost what you had when you set out. They kick you out of the castle and install a new knight in your place. You turn to turnip farming. Your tale has ended. miller.cs: State Text Actions 1 (start) "Sir Hero, you have just left your castle gate in search of adventure. You begin the journey with a horse, a sword, and a purse of coins. Along the road you meet a decrepit old man who offers you a gold coin. What do you do?" 1: accept the coin, add it to your purse: goto 3, coin=true 2: decline the coin, give to old man all of your money: goto 2, purse = false other: ride on: goto 2 2 "A mile past the old man a wandering grue menaces you with its fearsome claws. Grue are well known to be immune to the cut of a sword. What do you do?" 1: attack the grue with your something other than your sword: goto 4 if purse=true, goto 5 if purse=false 2: attack the grue with your sword: goto 8 3: ride past the grue,: goto 6 other: turn back to your castle: goto 9 if purse = true goto 3 if purse = false 3 "When you return to your castle you find that your serfs are very disappointed in your lack of heroism; they kick you out of the castle and install a new knight in your place. You turn to turnip farming." End program 4 "You rush to attack the grue, grabbing the only other weapon at hand, your coin purse. Your blows have no effect. The grue slashes at you but hits the coin purse, spilling gold coins everywhere. The grue gathers the coins and ignores you." No action. purse = false, goto 7 5 "You rush to attack the grue with you bare hands, and it swallows you whole. You have died." End program 6 "The grue leaps after you, taking down your noble steed from behind. You sneak away while it eats your horse." No action. horse=false, goto 7 7 "Escaping the fearsome grue, you finally have the good fortune to encounter a proper opponent, a dragon, which you defeat with your mighty sword. Its head would make a wondrous trophy hanging in your hall, but the treasure it hordes would also be most welcome. Which is more important?" 1: treasure is most important goto 10 if horse = true goto 11 if horse = false other: trophy is most important goto 10 if purse = true goto 12 if purse = false 8 "The grue swallows you, sword and all. You have died." End program 9 "When you return to your castle you find that your serfs are very disappointed in your lack of heroism, but you pay for a lavish feast with your purse of gold and all is well." End program 10 "You return to your castle in triumph. Huzzah!" End program 11 "Without a horse, the burden of the treasure proves too much for you; you perish on the road from fatigue." End program 12 "While impressed with your dragon-head trophy, the serfs at your castle are disappointed that not only did you fail to bring back any treasure, you lost what you had when you set out. They kick you out of the castle and install a new knight in your place. You turn to turnip farming." End programExplanation / Answer
You have posted this question before. Please rate this one also.
-----------------------------------------------------------------
import java.util.Scanner;
public class EasyGame
{ /** * @param args */
public static void main(String[] args)
{ // TODO Auto-generated method stub
Scanner input= new Scanner(System.in);
int state = 1,res;
boolean coin, purse = true, horse=true;
//Text description
if (state==1)
{
System.out.println("Sir Hero, you have just left your castle gate in search of adventure.");
System.out.println("You begin the journey with a horse, a sword, and a purse of coins.");
System.out.println("Along the road you meet a decrepit old man who offers you a gold coin.");
System.out.println("What do you do? ");
System.out.println("1. Accept coin, add it to your purse " +"2. Decline coin, but give the generous old man all your money " +"Other: Ignore the man and ride on ");
System.out.println("Enter an integer: ");
res = input.nextInt();
if(res==1)
{
System.out.println("When you return to your castle you find that your serfs are very disappointed");
System.out.println("in your lack of heroism; they kick you out of the castle and install a new knight");
System.out.println("in your place. You turn to turnip farming. ");
System.exit(1);
}
if(res==2)
{
System.out.println("Decline the coin, but give the generous old man all of your money");
System.out.println("You have lost the purse. ");
System.out.println("A mile past the old man a wandering grue menaces you with its fearsome claws.");
System.out.println("Grue are well known to be immune to the cut of a sword. What do you do? ");
System.out.println("1: Attack the grue with your something other than your sword");
System.out.println("2: Attack the grue with your sword "+"3: Ride past the grue "+"other: Turn back to your castle ");
System.out.println("Enter an integer: ");
res = input.nextInt();
}
if(res==3)
{
System.out.println("A mile past the old man a wandering grue menaces you with its fearsome claws.");
System.out.println("Grue are well known to be immune to the cut of a sword. What do you do? ");
System.out.println("1: Attack the grue with your something other than your sword");
System.out.println("2: Attack the grue with your sword "+"3: Ride past the grue "+"other: Turn back to your castle ");
System.out.println("Enter an integer: ");
res = input.nextInt();
}
}
if(state==2)
{
System.out.println("A mile past the old man a wandering grue menaces you with its fearsome claws.");
System.out.println("Grue are well known to be immune to the cut of a sword. What do you do? ");
System.out.println("1: Attack the grue with your something other than your sword");
System.out.println("2: Attack the grue with your sword "+"3: Ride past the grue "+"other: Turn back to your castle ");
System.out.println("Enter an integer: ");
res = input.nextInt();
if (res==1)
{
System.out.println("You rush to attack the grue, grabbing the only other weapon at hand, your coin purse.");
System.out.println("Your blows have no effect. The grue slashes at you but hits the coin purse, spilling gold");
System.out.println("coins everywhere. The grue gathers the coins and ignores you. ");
System.out.println("You rush to attack the grue with you bare hands, and it swallows you whole. You have died.");
return;
}
if(res==2)
{
System.out.println("The grue swallows you, sword and all. You have died.");
return;
}
if(res==3)
{
System.out.println("The grue leaps after you, taking down your noble steed from behind.");
System.out.println("You sneak away while it eats your horse.");
}
}
}
}
------------------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.