![]() |
|
Technology Computing, programming, science, electronics, telecommunications, etc. |
![]() |
|
Thread Tools | Display Modes |
|
![]() |
#1 | ||
Snowflake
Join Date: Mar 2006
Location: Dystopia
Posts: 13,136
|
This is, of course, semantics, but no, it doesn't.
I had a solution to design: how to test for two conditions. I figured, while either one is false, correct that one. Quote:
What could be simpler, or easier to understand? Let's say I am leaving the house. Did I lock the door (a)? Did I turn off the lights (b)? While either one is false: if (a) is false I lock the door, if (b) is false I turn off the lights. When neither one is false I am done. This is common sense. I understand that if I were doing this in the "real world" things would be more involved and this might cease to be feasible for a variety of reasons that I have yet to consider, but in essence, this is my conception of how loops work and what they are supposed to (are DESIGNED to) do. What I don't understand is why you guys find what I did confusing. I used regular, human logic. Quote:
I could put it back this way: Code:
while ((!passLength(password)) || (!containDigit(password))) { if (!passLength(password)) { cout << "Passwords must be at least 6 characters long" << endl; cout << "Please enter a password1: "; cin.getline(password, SIZE); (passLength(password)); //(a) } if (!containDigit(password)) { cout << "Passwords must include at least on digit (1-9)" << endl; cout << "Please enter a password2: "; cin.getline(password, SIZE); (containDigit(password)); //(b) } }
__________________
****************** There's a level of facility that everyone needs to accomplish, and from there it's a matter of deciding for yourself how important ultra-facility is to your expression. ... I found, like Joseph Campbell said, if you just follow whatever gives you a little joy or excitement or awe, then you're on the right track. . . . . . . . . . . . . . . . . . . . . . . . . . . Terry Bozzio Last edited by Flint; 11-28-2010 at 08:03 PM. |
||
![]() |
![]() |
![]() |
#2 | ||||||
I think this line's mostly filler.
Join Date: Jan 2003
Location: DC
Posts: 13,575
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
That is completely different. The tests no longer can change the password. That is logically a good program, though it could be more efficient. Moving the parts of main() into the tests did not result in an equivalent program. You could not with this programn (as I did above with the other one) remove the entire contents of the while loop and have an equivalent program.
__________________
_________________ |...............| We live in the nick of times. | Len 17, Wid 3 | |_______________| [pics] |
||||||
![]() |
![]() |
![]() |
#3 | |
Snowflake
Join Date: Mar 2006
Location: Dystopia
Posts: 13,136
|
Quote:
!(a) where (a) is a bool function evaluates true or false, it doesn't literally execute the function. Really, it doesn't. It doesn't do that. Really.
__________________
****************** There's a level of facility that everyone needs to accomplish, and from there it's a matter of deciding for yourself how important ultra-facility is to your expression. ... I found, like Joseph Campbell said, if you just follow whatever gives you a little joy or excitement or awe, then you're on the right track. . . . . . . . . . . . . . . . . . . . . . . . . . . Terry Bozzio |
|
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|