473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

About my School Project!

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...

Mar 26 '06 #1
3 1464
"The Last Ottoman" writes:
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.
Mar 26 '06 #2
The Last Ottoman wrote:
Just I said before, Since I don't know much about classes, I don't know
what to do.


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

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Mar 26 '06 #3
In article <11*********************@j33g2000cwa.googlegroups. com>,
"The Last Ottoman" <ot************@gmail.com> wrote:
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.

--
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.
Mar 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Los | last post by:
Hi, I am looking for some php/mysql scripts to set up a simple calendar for a school website. Most calendar scripts I have found are far to complex. The only functionality I want is that users...
0
by: Duffman | last post by:
I'm writing a program for a school project, which needs to grab text from a webpage, and send it to a variable. I read a few other posts about adding an inet (maybe not the right name) component,...
2
by: Rich R | last post by:
My client decided that all project personnel must be certified in MySQL. It was a contractual agreement between my client and his client. So: - I went to www.vue.com and signed up for the CORE...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
3
by: Andrej Hristoliubov | last post by:
I am the best c++ programmer in the whole wide world. Trust ME! My reference is Victor Bazarov,Valentin Samko,Alf P.Steinbach( Me and Alf actually intern together at Microsoft), and Bjarne...
1
by: Glen | last post by:
I need to make a project for school that intergrates Frontpage, access, word and powerpoint. I wanted to make something that would be usefull for work also. Anyways, here goes. I hope to create...
8
by: Christan | last post by:
I am currently taking a db course and my class is paired us into groups of 4s and our instructor had us download a template from the microsoft Access site for education to create and modify a...
0
by: Brett Baisley | last post by:
Hello At school, we use Emacs to make .cpp files for OpenGL. I got it working at home in windows using VC++.net, but in order to, I have to merge all of the files into one. Is there a way so...
5
by: Kevin Carne | last post by:
First, Merry Christmas. I have been doing intensive Java programming for two years in school (no choice on the language), but now I need to return to C++ because my resume is filled with it both in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.