1/* 2 * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz 3 * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz 4 * Distributed under the terms of the MIT License. 5 */ 6 7#include "LinearSpec.h" 8#include "Summand.h" 9#include "Variable.h" 10 11 12Summand::Summand(Summand* summand) 13 : 14 fCoeff(summand->Coeff()), 15 fVar(summand->Var()) 16{ 17} 18 19 20Summand::Summand(double coeff, Variable* var) 21 : 22 fCoeff(coeff), 23 fVar(var) 24{ 25} 26 27 28Summand::~Summand() 29{ 30 31} 32 33 34/** 35 * Gets the summmand's coefficient. 36 * 37 * @return the summand's coefficient 38 */ 39double 40Summand::Coeff() 41{ 42 return fCoeff; 43} 44 45 46/** 47 * Sets the summmand's coefficient. 48 * 49 * @param coeff coefficient 50 */ 51void 52Summand::SetCoeff(double coeff) 53{ 54 fCoeff = coeff; 55} 56 57 58/** 59 * Gets the summand's variable. 60 * 61 * @return the summand's variable 62 */ 63Variable* 64Summand::Var() 65{ 66 return fVar; 67} 68 69 70/** 71 * Sets the summand's variable. 72 * 73 * @param var variable 74 */ 75void 76Summand::SetVar(Variable* var) 77{ 78 fVar = var; 79} 80 81 82int32 83Summand::VariableIndex() 84{ 85 return fVar->Index(); 86} 87