C++ programming Help needed !!

Phobia_2

New member
hi people. I have just got some questions do do for my course. i am a bit stuck is there any one out there that can help me. The proble is that i have to create a minesweeper game that does the follows -
1.The playing area is a line of 26 squares
2. the squares are labelled A to Z
3.Ten mines are randomly placed in the squares in one group of three adjacent mines, two gruops of two adjacent mines and three single mines
4.None of the groups of mines, or single mines, may be immediatley adjacent to each other
5. the game begins by displaying a line containing the letters labeling the squares
6. the player selects the square by typing in the letter and pressing the return key
7.if the player selects a letter containing a mine the game is lost
THE ABOVE IS JUST PART OF THE PRBLEM CAN SOME ONE PLEASE LET ME KNOW HOW 2 GO ABOUT 2 DO THIS OR EVEN THE THEY WANT CAN GIVE ME SOME SOURCE CODE
PS THE GAMES HAS TO BE DONE AS A WINDOWS CONSOLE APPLICATION when choosing the type of project
thank alot
 
dude...

When asking for help, it would _really_ be beneficial if you would be much more concise in your questions...As it now stands, it seems like you want somebody to design the whole thing for you!

What part don't you understand? Have you drawn some things out on paper? Have you attempted to diagram any aspect of this project? Are there C++ issues that you're not sure about?

If it were me, I would do the ole' object approach for this type of problem...think about all the elements needed to makeup those squares. What kind of methods? What kind of properties/attributes? How will these pieces fit into the main application?

Anyhow, you really need to be much more concise in your question(s).
 
typedef enum said:
dude...


If it were me, I would do the ole' object approach for this type of problem...think about all the elements needed to makeup those squares. What kind of methods? What kind of properties/attributes? How will these pieces fit into the main application?

Anyhow, you really need to be much more concise in your question(s).

That's making it waaay too complicated. There's no need for any objects or methods here. Just an array of bools and a translation table (if you don't feel like casting the chars to int and doing it that way) to grab input for the alphabet. All you have to do to the input letter to change it to an array index is cast it to char and subtract 97 (lowercase, 65 for uppercase, choose one and use an assert).


bool mines[26]; //true if mine, false if not

Use some loops with rand() and % to fill your array. This project will be 100 lines of code max.

EDIT: I wish my homework was still this easy.
 
Last edited:
Quite frankly, doing it the "easy way" (hint...the way that will get the job done in the fewest lines of code) is _not_ the answer when talking about a classroom-type assignment, IMHO.

This is precisely why so many people jump into their first job completely unprepared to do things the "right way" because they were too accustomed to just slapping something together that cuts to the chase.

Based on what little the original poster stated, it sounded to me as if the guy wanted somebody else to do his project for him.
 
typedef enum said:
Quite frankly, doing it the "easy way" (hint...the way that will get the job done in the fewest lines of code) is _not_ the answer when talking about a classroom-type assignment, IMHO.

This is precisely why so many people jump into their first job completely unprepared to do things the "right way" because they were too accustomed to just slapping something together that cuts to the chase.

Based on what little the original poster stated, it sounded to me as if the guy wanted somebody else to do his project for him.

There's no such thing as the right way, only pre and post conditions. You'd only be unprepared if you can't follow instructions.

Other than that, you're supposted to get into the habit early of writing the simplest, most efficient code possible. This means not using useless classes/methods when they aren't explicitly called for. Follow the instructions to the T and you should be fine.

Plus you're first paragraph is the exact opposite of what I have been learning in C++ for the past 3 years. It is the exact opposite of what every professor has ever told me, and I'd probably be failing if I were to follow stupid advise like that.

Either way, I have too much programming to do to do this chode's homework for him. If he can't figure out how to solve problems on his own, he'd better practice his lines for the future: "would you like fries with that?"
 
Vadatajs said:
There's no such thing as the right way, only pre and post conditions. You'd only be unprepared if you can't follow instructions.

Other than that, you're supposted to get into the habit early of writing the simplest, most efficient code possible. This means not using useless classes/methods when they aren't explicitly called for. Follow the instructions to the T and you should be fine.

Plus you're first paragraph is the exact opposite of what I have been learning in C++ for the past 3 years. It is the exact opposite of what every professor has ever told me, and I'd probably be failing if I were to follow stupid advise like that.

Either way, I have too much programming to do to do this chode's homework for him. If he can't figure out how to solve problems on his own, he'd better practice his lines for the future: "would you like fries with that?"

You could be write, but OOP is a standard now and needs to be taught from the start. Usually you get your 'basic' understanding of programming from a language other than C++, it's way too complicated of a programming language to start someone of on. That said, I really hope institutions of "higher" learning are NOT teaching C++ without the important concepts of Object Oriented Programming.

And as for the second post, yah I agree -- ask a specific queston(s) don't ask us to design, implement and test your ASSIGNMENT : )
 
Smeerak said:
You could be write, but OOP is a standard now and needs to be taught from the start. Usually you get your 'basic' understanding of programming from a language other than C++, it's way too complicated of a programming language to start someone of on. That said, I really hope institutions of "higher" learning are NOT teaching C++ without the important concepts of Object Oriented Programming.

And as for the second post, yah I agree -- ask a specific queston(s) don't ask us to design, implement and test your ASSIGNMENT : )

OOP is not everything; not even close. It's important, but it shouldn't be taught first.

C++ is what I started on, then x86 assembly was next (actually I learned ASM alongside object oriented c++). C++ is a great language to start on because it provides a strong foundation in imperative programming concepts, as well as OOP. It is a very versitile language and understanding how it works makes it much easier to learn other languages that use the same concepts, but are more specialized for other applications (embedded apps, applets, drivers, compilers..etc).



I would agree with you if you said that colleges shouldn't start with ASM, or functional languages like LISP.
 
Vadatajs said:
OOP is not everything; not even close. It's important, but it shouldn't be taught first.

C++ is what I started on, then x86 assembly was next (actually I learned ASM alongside object oriented c++). C++ is a great language to start on because it provides a strong foundation in imperative programming concepts, as well as OOP. It is a very versitile language and understanding how it works makes it much easier to learn other languages that use the same concepts, but are more specialized for other applications (embedded apps, applets, drivers, compilers..etc).



I would agree with you if you said that colleges shouldn't start with ASM, or functional languages like LISP.

I'm agreeing with you about 'shouldn't be taught first' That's why I said usually a different language is taught to get the hang of loops, function calls etc.. BASIC (at ages under 17) and even JAVA as an entry level University course.

And you are 100% correct, I tend to forget to forget the embedded side of things, or rather that what my interrest is but usually others who ask q's about programming are always only concerned about the software side of things. (windows apps etc...)

My learning progression was as follows.

Before University - BASIC
1st year through 2nd year JAVA
Work term (20 months) C++ -- so learned C++ on the fly :)
ASM for the SPARC and next term Embedded C
Somewhere I'm going to have to go pick up a good book on 8088 assembly code because my assembler background is strictly RISC based.

nice chatting with you,
 
This is the book I used for ASM. It was pretty good. I think it did a good enough job explaining the basic instructions (16 & 32 bit), but if you want to learn SSE, SSE2 and 3dNow, you will have to find another one.

This is the only CS text I have ever sold back, and I'm kicking myself for it now. Assembly isn't widely used anymore, and probably isn't necessary unless you are involved with compiler design or something.

Honestly, my favorite language right now is LISP. I'm trying to find a good book on CLOS (OO lisp).
 
Thanks for the link, I'll get it in the new year...

LISP eh ?

Can you elaborate with some introductory links ? I'm always looking for new languages
 
Smeerak said:
Thanks for the link, I'll get it in the new year...

LISP eh ?

Can you elaborate with some introductory links ? I'm always looking for new languages

LISP is very different from C/C++.

This is the LISP primer we used as a text for LISP in class.

This was also very helpful. It's an online interactive tutorial, where they have you practice what they tell you right there, and correct it. It was a life saver when it came to actually writing lisp programs and getting the syntax correct. It requires registration, but it's free, and they don't spam you.

Language specifics (and more technical information) can be found .here.

Allegro is a good lisp interpriter for win32 (emacs also for win/unix). You have to register for a trial (free, 60 day) though, good enough for educational purposes. It includes some documentation about lisp also. Most linux distributions and freebsd (I prefer over linux) include emacs and its lisp documentation. I don't have any links handy for any allegro, or emacs tutorials though. I used Allegro for my projects.

Wow, talk about a thread hijacking.
 
Last edited:
Vadatajs said:
Wow, talk about a thread hijacking.

LOL! All in the name of EDUCATION ... so it's ok! hehe ... I'll check it out after exams ugh ... can't wait to be rid of this semester. So you can use lisp for pretty much anything?

Thanks again,
 
Smeerak said:
LOL! All in the name of EDUCATION ... so it's ok! hehe ... I'll check it out after exams ugh ... can't wait to be rid of this semester. So you can use lisp for pretty much anything?

Thanks again,

That question will really answer itself when you read the tutorials, but a basic answer is "not really." Like java & basic LISP is interprited, so the code is executed expression by expression, without compiling to an executable. The way the lisp syntax works, the code is the same structure as the data, which is confusing at first, but easy to adapt to. This all means that LISP programs can modify their code during execution. The problem with common lisp is, it needs the eval function to execute anything. Eval is the interpriter loop, basically a generic function that can execute any other lisp function. It's not an easy language to explain.

I can't wait for this semister to end either.
 
Last edited:
Back
Top