All pastes #436023 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-12 09:30 UTC
rendered paste body
#include <iostream>

using namespace std;

class Logic
 {	
 private:
	 bool inputA;
	 bool inputB;
 public:
	void setInputA(bool);
	void setInputB(bool);
	bool getOutput();
	void setFunction(int);
	int op;


 };

 void Logic::setInputA(bool a)
 {	
		inputA = a;
 }

void  Logic::setInputB(bool b)
 {
		inputB = b;
 }

 void Logic::setFunction(int operation)
 {
		op = operation;
 }

 bool Logic::getOutput()
 {
	if (op == 1)
		return inputA && inputB;
	if (op == 2)
		return inputA || inputB;
	if (op == 3)
	{
		if (inputA == true && inputB == true)
			return false;
		if (inputA == false && inputB == true)
			return true;
		if (inputA == true && inputB == false)
			return true;
		if (inputA == false && inputB == false)
			return false;
	}

 }