Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

What's wrong with it?

SofieMLPA
SofieMLPA

Thanks to a few people here on Repl, I was able to get a good start on this game that I'm making.
I ran into a little trouble though. Does anyone know what's wrong with my code? Thanks!!

3 years ago

Voters

Comments

TopNew
1
CodeLongAndPros
CodeLongAndPros

And then put lines 2-10 inside:

class MainClass { public static void Main (string[] args) { {Code goes here} } }
3 years ago
1
SofieMLPA
SofieMLPA

@CodeLongAndPros

Ohhhh! Thanks!

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA
You'll also need to replace foo(); with a actual bit of code, because foo() does not exist.

3 years ago
1
CodeLongAndPros
CodeLongAndPros

At line 2 you need to insert this:

string input = Console.NextLine();
3 years ago
1
SofieMLPA
SofieMLPA

@CodeLongAndPros

wait, now there are a bunch of new errors.

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA

Line 5 needs to be:

string input = Console.ReadLine();

And please replace foo();
and
bar();
With whatever code you want to run.

3 years ago
1
SofieMLPA
SofieMLPA

@CodeLongAndPros

Do I replace Console.NextLine with WriteLine or ReadLine?

3 years ago
1
SofieMLPA
SofieMLPA

@CodeLongAndPros

Wait, don't i put the code i want to run in the ones that say spam and hello and i hate spam?

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA

Do I replace Console.NextLine with WriteLine or ReadLine?

It should be Console.ReadLine();

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA

Wait, don't i put the code i want to run in the ones that say spam and hello and i hate spam?

Do you see the brackets ({}) on lines 6 & 7? You put the code you want to run when the user says yes in-between those. Same with the else if and else

3 years ago
1
SofieMLPA
SofieMLPA

@CodeLongAndPros

Oh, ok. But do I replace the NextLine on line 5 or not? And it still won't work!!! I'm so sorry i dragged you into the mess of a code i made lol.

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA

But do I replace the nextLin one or not

I don't see a nextLin in your repl.

3 years ago
1
SofieMLPA
SofieMLPA

@SofieMLPA

If i put ReadLine in place of NextLine, It will not display anything. If I replace it with WriteLine, it will give me another error.

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA
You'll have to enter it exactly as in the quotes.
If you don't enter Yes., it won't work. Same with No.

3 years ago
1
SofieMLPA
SofieMLPA

@CodeLongAndPros

Ok. So i just put the same format of code for every question? That's gonna get complex.

3 years ago
1
SofieMLPA
SofieMLPA

@SofieMLPA

And, every time I run the code, a bunch of numbers and semicolons show up and i have to delete them. What's up with that?

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA
You could also do this:

string input = Console.ReadLine(); switch(input) { case 'yes': //Run code break; case 'no': //code break; }
3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA
Can you post a screenshot of the behavior?

3 years ago
1
SofieMLPA
SofieMLPA

@CodeLongAndPros

Ok, ill try. i'm on an Acer computer and idk if it;'s possible. Let me try on my ipad.

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA
Press -PrintScreen
to capture your screen, if your are on Windows 10. In KDE, it's printscreen.

3 years ago
1
SofieMLPA
SofieMLPA

@CodeLongAndPros

0054FAA5-2B14-47C1-B6B6-59539F2350EA

3 years ago
1
CodeLongAndPros
CodeLongAndPros

@SofieMLPA
That's strange. Mine runs fine:

image

3 years ago
Load more