About my School Project!

T

The Last Ottoman

Hi,
I'm a student in Turkey, and my C++ project was quite hard for me.
Since I have never write any program in C++ (although I'm so good at
C), I have no idea what to do.

if I understand only a little part of the problem, I think I can solve
it.
Here is a small part of the problem...

There is a multidimensional array 10 x 10. There are doctors and humans
on the array with the sign 'D' and 'H'... Humans are sick, so they want
to move ahead to Doctors. but Doctors move randomly.. I have to design
a class system for humans to find the nearest doctor and move toward
him.

Just I said before, Since I don't know much about classes, I don't know
what to do.
I appreciate if you help me...
Thanks you all
Best Wishes...
 
O

osmium

The Last Ottoman said:
I'm a student in Turkey, and my C++ project was quite hard for me.
Since I have never write any program in C++ (although I'm so good at
C), I have no idea what to do.

if I understand only a little part of the problem, I think I can solve
it.
Here is a small part of the problem...

There is a multidimensional array 10 x 10. There are doctors and humans
on the array with the sign 'D' and 'H'... Humans are sick, so they want
to move ahead to Doctors. but Doctors move randomly.. I have to design
a class system for humans to find the nearest doctor and move toward
him.

Just I said before, Since I don't know much about classes, I don't know
what to do.

The first problem is to analyze the thing logically, only then can you start
writing a program. You say the doctors move randomly. If this is so the
best approach is probably for a human to stay where he is and wait for a
doctor to bump into him. I assume you misspoke and actually meant the
doctors are located at random positions. If that is so, I guess the best
thing for a human to do is search in a spiral starting in his current
location. Which means keeping track of where he has been so he doesn't go
there again. When he hits the edge of a board, he will have to "unwind" in
the next outer layer.

I would start with a board populated by one human and one doctor. Indeed,
the whole point of using classes here seems to be the possibility that you
can have multiple "actors". If my guess, as to what the problem definition
is, is correct there is not much for a doctor to do. He just sits at some
x,y coordinate waiting for a patient. A human has to keep track of his
origin and his current position. If he goes in a clockwise direction until
he hits an edge and then goes CCW to the next edge, ISTM his entire history
is captured in those two factoids. So:

class Human
{
public:
Human(int xa, int ya);
bool move(); // move one unit and report success or failure
void show(); // for debugging
private:
int xorigin;
int yorigin;
int x; // current location
int y;
};

I would use a global variable for the board. This is much frowned upon by
most regulars on this newsgroup. Which makes me wonder: Are these the same
people that leave the turkey in the kitchen at Thanksgiving? (A little bit
of American humor, there.)

You may get advise to use vectors instead of arrays. It is clear that such
advise is inconsistent with your instructors chosen teaching sequence -
ignore such advise.
 
D

Daniel T.

"The Last Ottoman said:
Since I have never write any program in C++ (although I'm so good at
C), I have no idea what to do.

if I understand only a little part of the problem, I think I can solve
it.
Here is a small part of the problem...

There is a multidimensional array 10 x 10. There are doctors and humans
on the array with the sign 'D' and 'H'... Humans are sick, so they want
to move ahead to Doctors. but Doctors move randomly.. I have to design
a class system for humans to find the nearest doctor and move toward
him.

Just I said before, Since I don't know much about classes, I don't know
what to do.

Being good in C should make this easy. First write it in C, then look
for code duplication that C++ structures would help remove. If you have
a problem, post the code you have and we'll have a look.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top