Wow, looking at these, I feel like a CEO of a very serious corporation which is dedicated to conquer the world.
Keep on guys, I'll pump the wages![]()
Wow, looking at these, I feel like a CEO of a very serious corporation which is dedicated to conquer the world.
Keep on guys, I'll pump the wages![]()
That code looks pretty easy, I should try C++, it's to Java like German is to Dutch or so.
Also I noticed there is a fault here:
in the if-clause you check whether option is EASY_LEVEL, but since option is an integer, it cannot be a string and besides that, option was only assigned a number so that can never ever return true.std::cout<< "1=Easy\n";
std::cout<< "2=Medium\n";
std::cout<< "3=Hard\n";
std::cin>> Option;
if (Option == EASY_LEVEL)
You either need to use a different check or turn option into a string and add three more lines and another variable and....
Despite Blodrast saying this was bad style, I would use
Or you could change the start to say:if (Option == 1)
the three ifs could also be a case-option but then you could later check with#include <string>
int Option;
string difficulty;
bool Word_Complete = false;
std::cout<< "Game intructions\n";
std::cout<< "Please select a difficulty level\n";
std::cout<< "1=Easy\n";
std::cout<< "2=Medium\n";
std::cout<< "3=Hard\n";
std::cin>> Option;
if (option == 1) {
difficulty = "EASY_LEVEL"}
if (option == 2) {
difficulty = "MEDIUM_LEVEL"}
if (option == 3) {
difficulty = "HARD_LEVEL"}
but in Java checking strings does not work like this IIRC, so the condition may need a big change.if (difficulty == "EASY_LEVEL")
{
std::cout<< "Display scambled word Easy\n";
}
Ok, guess this really needs something else to check what is inside the string, but I would actually prefer numbers for such a small program anyway...
Last edited by Husar; 11-22-2006 at 23:47.
![]()
![]()
"Topic is tired and needs a nap." - Tosa Inu
The_Doctor - the program ends after displaying the difficulty level because you haven't put anything after the switch statement that displays the difficulty level. If you want the program to continue after that, either add what else the code needs to do or put the entire thing in a loop as Sigurd Fafnesbane has done.
I would recommend using <iostream>instead of <iostream.h> and then put the phrase "using namespace std;" under it. Then you won't have to put std:: in front of every cout and cin. Just a little trick.
Husar - he's defined EASY_LEVEL to be 1, so the compiler treats every "EASY_LEVEL" as a 1. I guess Java doesn't have that feature...
You're right, I didn't notice that.Originally Posted by Alexander the Pretty Good
At least my lazy brain got to think about some code again.![]()
![]()
![]()
"Topic is tired and needs a nap." - Tosa Inu
It works now.![]()
I tried the code on one of the computers in university and it worked.
I wonder why it does not work on my computer?
So when are we moving on to conquest, boys?Originally Posted by The_Doctor
Don't spoil my fun, hey!
Nothing appears to be wrong with that code in your first post apart from the booleans need to be initialised.
“The majestic equality of the laws prohibits the rich and the poor alike from sleeping under bridges, begging in the streets and stealing bread.” - Anatole France
"The law is like a spider’s web. The small are caught, and the great tear it up.” - Anacharsis
There is. He wants loops, but his while loops don't do anything, because they end in a semicolon. His code IS, both syntactically, and semantically, correct, yes, but I very much doubt that was what he wanted (while loops that do nothing), at least from what he explained.Originally Posted by Manco Capac
Therapy helps, but screaming obscenities is cheaper.
LoL. I think you install his mini-game, and pick "Medium". No one ever picks medium. Then 'the plan' is revealed.Originally Posted by LeftEyeNine
![]()
Be well. Do good. Keep in touch.
Bookmarks