//----------------------------------------------------------------------------
#include "booleanclass.h"
//----------------------------------------------------------------------------
//----Friends
//----------------------------------------------------------------------------
ostream& operator <<(ostream& OutputStream, const boolean& ToOutput) {

if (ToOutput.Value) 
    OutputStream << "TRUE";
else OutputStream << "FALSE";

return(OutputStream);
}
//----------------------------------------------------------------------------
//----Public functions
//----------------------------------------------------------------------------
//----Default constructor
boolean::boolean(void) {

SetFromCBoolean(FALSE);
}
//----------------------------------------------------------------------------
//----Initial value constructor
boolean::boolean(int InitialValue) {

SetFromCBoolean(InitialValue);
}
//----------------------------------------------------------------------------
//----AND operation. TRUE if self and argument are TRUE, else FALSE
boolean boolean::And(boolean LHS) {

boolean ReturnBoolean;

ReturnBoolean.Value = Value && LHS.Value;
return(ReturnBoolean);
}
//----------------------------------------------------------------------------
//----OR operation. TRUE if self or argument are TRUE, else FALSE
boolean boolean::Or(boolean LHS) {

boolean ReturnBoolean;

ReturnBoolean.Value = Value || LHS.Value;
return(ReturnBoolean);
}
//----------------------------------------------------------------------------
//----NOT operation. TRUE if self is FALSE, else FALSE
boolean boolean::Not(void) {

boolean ReturnBoolean;

ReturnBoolean.Value = ! Value;
return(ReturnBoolean);
}
//----------------------------------------------------------------------------
//----XOR operation. TRUE if self or argument (not both) are TRUE, else FALSE
boolean boolean::Xor(boolean LHS) {

boolean ReturnBoolean;

return((Value && !LHS.Value) || (!Value && LHS.Value));
}
//----------------------------------------------------------------------------
//----EQUIVALENT operation. TRUE if self and argument are the same
boolean boolean::Equivalent(boolean LHS) {

boolean ReturnBoolean;

ReturnBoolean.Value = (Value == LHS.Value);
return(ReturnBoolean);
}
//----------------------------------------------------------------------------
//----IMPLIES operation. FALSE if self is TRUE argument is FALSE, else TRUE
boolean boolean::Implies(boolean LHS) {

boolean ReturnBoolean;

return((And(LHS.Not())).Not());
}
//----------------------------------------------------------------------------
//----Private functions
//----------------------------------------------------------------------------
//----Set from a C boolean value (int)
void boolean::SetFromCBoolean(int SetToThis) {

Value = SetToThis;
}
//----------------------------------------------------------------------------
