I took another look
Quote:
Sample CLASS
(the Clothing Class to make?)
Clothing
Clothing( string kind );
void wash( );
void dry( );
void wear( );
bool isClean( );
bool isWet( );
bool isDirty( );
String my_Kind;
bool my_isClean;
bool my_isWet;
|
Did the teacher tell you that? If so then once again it proves half of them don't know what they are talking about.
Let me please explain.
This class is able to wash. And to dry. And to wear.
Think about it. Look at your socks. Do they know how to wash themselves? You see them walking to the washing machine? Do they make you wearing them? How do they do that?
Quote:
|
Wear me or I'll make me smelly!
|
Do they make themselves dirty? How?
This teacher has interesting clothes man

.
In real life, you'll need a class Clothes which only hold their state:
- Am I clean/dirty?
- Am I dry/wet?
- Am I in a washing machine?
- Am I in a dryer?
- Am I being worn?
- Am I stored on a file?
- Can I be used as a fire extinguisher in case of a an emergency?
The last one is important to show that a class Clothes doesn't have to know why it exists in the first place! This is Object Orientation.
And in real life, you'll create a class WashingMachine:
- Wash()
- HalfDry()
- Notify(Event* event) //Washing ready, HalfDryReady, TimerDone etc.
- DoorIsOpen() // safety!
- DoorIsLocked //So door is closed AND locked. Safety, machine runs!
- HasWeight() //No clothes in it burns the motor!
See what I mean?
