i have got this OOP project of implementing minesweeper using classes.Can anybody just hint me what classes i have to use and what would be their relationship like association,containment,weak containment and strong like that.anybody plz.If i failed to do so i would be getting an f!!!!!plz!!!!!!!!!!!!!!

If you're thinking about "relationships" like association, containment, and such, then you're not thinking about solving the problem. Think about what your program would be doing when running minesweeper, and then the classes that you find convenient to use will fall out directly from the types of objects you're thinking of.

ya i know that but i don`t know how many classes should be made like should i make classes of mines,board,timer and what relationship these classes are holding???likewise

ya i know that

Then all you need to do is apply it. Rather than think of how many classes you need or the relationships between classes this early, think of a solution and map the unique collections of data and behavior to classes. If you get bogged down in OOP theory, you'll never get anything done. :)

The answer is "that depends" - you have to think about how you want to go about making the program - there's no right or wrong answer, because it depends largely on how simple or complicated your program will be. Entities such as Mine or Board are fairly important to a minesweeper game, however, a timer might be an optional addon which you leave til the basic mechanics are working. (obviously you'd leave provision for one to be added).

If you take a look at Windows minesweeper, it's quite a complicated program, with a changing face, different coloured numbers, score board, etc.. but it probably started out as just a board of clickable squares.

It would also be worth noting that OOP is just a tool, so no need to spend ages pouring over class diagrams & relationships - if you find that your program doesn't benefit from OOP, don't use it.

as now i have come to know and i have made the relationships about classes now i am having a big problem of drawing the board of minesweeper .i have to draw it without using mfc and how about the timer thing.the timer should go on.

ya.its good but i am worried out the timer thing that is continously updating.can anybody pelase tell me what to do about the timer thing.i have to make function that takes input and updates timer continously at the same place.the timer is updated irrespective of the input given or not

Member Avatar for iamthwee

ya.its good but i am worried out the timer thing that is continously updating.can anybody pelase tell me what to do about the timer thing.i have to make function that takes input and updates timer continously at the same place.the timer is updated irrespective of the input given or not

Well, how are you handling the GUI components of the game?

Options.
1. Use a rather hackish console display with <windows.h> commands
2. Use win32 -yuck
3. Use mfc - yucky
4. Use C# - yay.

:lol:

In any case the GUI should be the last thing you should consider. First you have to get all your methods for your class ready. For instance,

... mines,board,timer,player's move,set bombs,check if bomb,uncover squares, number uncovered squares...and so on

hey guyz!!! thank ya all for ur comments .i `ve made all the classes and its working good now what i need is some informationa bout the timer class.is there any headre file fron where i can display a stopwatch in digits.........please tell me cauz im in dire need for this.

Member Avatar for iamthwee

You have two options.

You can use the <time.h> file.

Or Sleep from <windows.h>

Although, you haven't told us how you're handling the GUI...

well what functions i have to use in time.h and i like to dispaly timer constantly in the same place..tell me what functions display timers like i have to start timer when the game starts and end it when it ends..
i have made cell class and made it friend of the main minesweeper class and then i`ve made input class and it is a friend too of the minesweeper class.plz reply me about the time.h class

Member Avatar for iamthwee

i like to dispaly timer constantly in the same place

If you're using windows, you have to clear the screen to give the illusion of a constantly updating timer.

I assume you're doing this from a console window... although you haven't said. And you haven't told us which operating system you are using, so I'm assuming you're using windows.

tell me what functions display timers like i have to start timer when the game starts and end it when it ends.

I would rather use the Sleep function than the stuff from <time.h>...

When you eventually decide to answer these questions...

How are you handling the GUI components of the game?

  1. Use a rather hackish console display with <windows.h> commands
  2. Use win32 -yuck
  3. Use mfc - yucky
  4. Use C# - yay.

What operating system are you using?

Then I can proceed to try answer your questions more specifically.

I would rather use the Sleep function than the stuff from <time.h>...

Use the

clock

function. If you use the

sleep

function you will have to implement a clock function from scratch.

1. Use a rather hackish console display with <windows.h> commands
2. Use win32 -yuck
3. Use mfc - yucky
4. Use C# - yay.

A more reasonable comparison will be

1. Use a rather hackish console display with <windows.h> commands
        Adv - Simple, use C++
        Disadv - Ugly

2. Use win32 -yuck ( for newbies perhaps )
        Adv - faster, smaller executable, better control of the program, use C++
        Disadv - difficult if you don't have the guts and time

3. Use mfc
        Adv - Easier than using Win32 API, same look and feel, use C++, a lot of examples in the internet especially www.codeproject.com 
        Disadv - A slightly larger executable, less control on the program

4. Use Managed C++
        Adv - Easier than using Win32 API and perhaps MFC, same look and feel, use C++
        Disadv - Don't know much about this, but less number of examples in the net.

5. Use C# -
        Adv - None that I can think of but Iamthwee is welcome to disagree ;) 
        Disadv - Learn C#, port your C++ program to C#...

Hey Fellas,

I was wondering if I could write a simple code that erases the input display information once a user enters it. For example, I was going to write a simple program that asks for the user's name and then have the trailing display information erased from the program. Here's the code that I wrote:


#include <iostream>
using namespace std;

int main ()

{

char name [10];

cout << "May I have your name please?" << endl;

cin >> name;

cin.ignore();

cout << "Hey, " << name;

cin.get();

return 0;

}
When the user enters their information their screen would look like this:

May I have your name please? You
Hey, You

....so my question basically is how do I get rid of "May I have your name please?" so that it looks like this on their screen:

Hey, You

____

Member Avatar for iamthwee

I was going to write a simple program that asks for the user's name and then have the trailing display information erased from the program.

You need to clear da screen... Tee he he. So you're using a console based GUI then?

Check this exampleby Dave Sinkula. It is fairly simple. If you want a more complicated one, there is an example by me in the same thread. But I think Dave's example will do.

Edit: Looks like Dave's example will work only for overwriting the same line. Not sure though. You can find out yourself. If that is the case, maybe my example will be the only way. :sad:

Member Avatar for iamthwee

If you come over to the java forums I'll show you how to make it pretty.
:lol:

[tries to recruit a java newbie]

I knew there was something evil about you...

Member Avatar for iamthwee

I knew there was something evil about you...

Little ol' me, no? :sad:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.