Connecting Tech Pros Worldwide Help | Site Map

About my School Project!

  #1  
Old March 26th, 2006, 03:05 PM
The Last Ottoman
Guest
 
Posts: n/a
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...

  #2  
Old March 26th, 2006, 04:45 PM
osmium
Guest
 
Posts: n/a

re: About my School Project!


"The Last Ottoman" writes:
[color=blue]
> 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.[/color]

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.


  #3  
Old March 26th, 2006, 04:55 PM
Phlip
Guest
 
Posts: n/a

re: About my School Project!


The Last Ottoman wrote:
[color=blue]
> Just I said before, Since I don't know much about classes, I don't know
> what to do.[/color]

Tell us, in pseudo-code, how you would do this in C.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!


  #4  
Old March 26th, 2006, 05:55 PM
Daniel T.
Guest
 
Posts: n/a

re: About my School Project!


In article <1143384844.300742.98560@j33g2000cwa.googlegroups. com>,
"The Last Ottoman" <ottomanthelast@gmail.com> wrote:
[color=blue]
> 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.[/color]

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.

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
School project: C++ RPG game. Karlsen answers 5 February 9th, 2008 09:37 AM
What so special about PostgreSQL and other RDBMS? Sarah Tanembaum answers 125 July 20th, 2005 04:46 AM
Question about how to use INET Duffman answers 0 July 17th, 2005 08:59 PM
What so special about PostgreSQL and other RDBMS? Sarah Tanembaum answers 115 July 17th, 2005 06:31 AM