Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

String error on simple text game

Garrett85Garrett85 Posts: 168Member
Take a look at the program bellow.

[code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TextAdventureGame
{
class adventure
{
static void Main()
{
string person;
string occupation;
string seaCreature;
string animal;
string friend;
string tool;
string problem;

Console.WriteLine("Simple Adventure Game");

Console.Write("What is your name? ");
person = Console.ReadLine();

Console.Write("What is your occupation? ");
occupation = Console.ReadLine();

Console.Write("Please tell me your favorite animal: ");
animal = Console.ReadLine();

Console.Write("What is the name of your friend? ");
friend = Console.ReadLine();

Console.Write("Name a problem you might face: ");
problem = Console.ReadLine();

Console.Write("Name a tool: ");
tool = Console.ReadLine();

Console.Write("Please give me the name of a sea creature: ");
seaCreature = Console.ReadLine();

Console.WriteLine();
Console.WriteLine();

//write the story
Console.WriteLine("One day there was a person named {0}. Now, {0} was usually ", person);
Console.WriteLine("very content to work as a {0}, but sometimes the job", occupation);
Console.WriteLine("was very difficult.");
Console.WriteLine("One day, {0} discovered that the heardbreak of {1} had ", person, problem);
Console.WriteLine("occured just one time to often. "I can't stand being a ");
Console.WriteLine("{0} any more!" yelled {1}, as he hurled away his ", occupation, person);
Console.WriteLine("{0} in anger, No {1} will keep me from fulfilling", tool, problem);
Console.WriteLine("My dreams! What I really want, said {0}, is to be just like ", person);
Console.WriteLine("{0). Now THAT'S somebody to admire. So {1} put away the ", friend, person);
Console.WriteLine("{0} forever, and followed {1} into the pastoral", tool, friend);
Console.WriteLine("world of {0}-ranching. Eventually, {1} was able to ", animal, person);
Console.WriteLine("retire, as happy as {0}", seaCreature);

Console.WriteLine();
Console.WriteLine();

//Ask for Enter to quite
Console.Write("Press Enter to continue!");
Console.ReadLine();

} //end Main
} //end class
} //end namespace
[/code]

When I compile the program in MS Visual C# 2008 it runs the program until it gets to the line

[code]
Console.WriteLine("{0). Now THAT'S somebody to admire. So {1} put away the ", friend, person);
[/code]

The program does not run after that point and the compiler says that somethings wrong with my string formating. I got this program from the book "Microsoft C# Programming for the absolute beginner"

Can someone please help me out I would really appreciate it. Thanks.

Comments

Sign In or Register to comment.