LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   help to design class diagram (https://www.linuxquestions.org/questions/programming-9/help-to-design-class-diagram-759813/)

naveenisback 10-05-2009 09:12 AM

help to design class diagram
 
Hi to all


I want to know how to relate classes in c++.

For Ex:

My project is to get the system information like monitor, cpu, os , network..

So how can i design a class diagram.. which 1 is good among following

1.take computer as base class , and monitor , cpu, os as derived class.

2. Take computer as base class and treat Monitor cpu, OS as agregates of Computer..


And one more question

How can i implement if i consider any one among above.


How to upload a diagram to this forum..
sori for bad english

indienick 10-05-2009 09:43 AM

One of the best (if not only) ways to get help with homework - not that I have anything against helping people with their homework - is to show us some of the work you have already done.

As far as uploading a diagram, I suggest uploading the file to some personal web space (if you have some, that is) and just posting a link.

:)

johnsfine 10-05-2009 10:04 AM

Quote:

Originally Posted by naveenisback (Post 3708341)
My project is to get the system information like monitor, cpu, os , network..

Your other threads don't sound like homework. So I don't know how to react to this one that does.

Quote:

1.take computer as base class , and monitor , cpu, os as derived class.
When you try to model physical reality with object oriented inheritance you are looking for "is a kind of" relationships. So "computer" as base class for "monitor" would make sense if "a monitor is a kind of computer". You can't intend that, and I can't think of anything else you might intend with computer as the base class for monitor.

Did you mean computer_part as the base class?

Quote:

2. Take computer as base class and treat Monitor cpu, OS as agregates of Computer..
It's even harder to figure out how that is supposed to make sense.

A computer might be an aggregate of computer_parts.

I haven't looked at the source code for the open source project lshw. But it seems to be available easily. A web page on that subject says it is C++ code. It takes a very structured approach to reporting the characteristics of computer components. So it might be a good example to look at. There is a clear advantage to looking at the work of someone who did a good job at a similar task, rather than asking the random opinions of those who might reply to a thread like this.


All times are GMT -5. The time now is 08:04 AM.