According to the instructions you have supplied, it looks like you already have a class that's been defined, possibly as a counter? It's very hard to understand what you're trying to accomplish since I don't know the entire context of your program.
From the instructions, it says that atMin and atMax are supposed to be part of the said class and it's supposed to check the counter object to check to see if it has reached it's min/max value. Can you supply at least this function so I can help guide you in the right direction?
Edit: Going off of your previous post, I'm assuming there is no code with this either. I'm also assuming we're talking about some pseudo Counter class. What really confuses me is on your other post, you're having problems with converting a for loop to a while loop, but yet in this one, you're trying to solve a problem that involves classes and members. If they're related, then the other one needs to be changed.
But, back to this one. I'm not sure what kind of teacher you have, but this question is severely taken out of context and is almost impossible to know what the "correct" answer should be. My suggestion is that you look at the text book of where this question came from, or wherever else you can turn for help. I'll also provide you with my best guess as to how these functions should operate.
1 2 3 4 5 6 7 8 9 10 11 12
|
bool Counter::atMax() {
// This line will first evaluate value and maxVal
// If they're the same, then the function returns true
return (this.value == this.maxVal);
}
bool Counter::atMin() {
// This line will evaluate the opposite of value
// If it's non-zero, the function will return false
// If it's zero, the function will return true
return !this.value;
}
|