📄 effects.c
字号:
/****************************************************************//* NAME: Konstantinos Roussos *//* ACCT: knr *//* FILE: Effects.C *//* ASGN: Final *//* DATE: Tue Jun 14 01:04:03 1994 *//****************************************************************//* * Copyright 1994, Brown University, Providence, RI * See end of file for full copyright information */#include "Effects.H"/****************************************************************//* *//* Function Name: Effect::Effect *//* Parameters: *//* Time start_time : when an effect starts *//* const XDString& symbol : the symbol of the effect *//* Type kind : what kind of effect it is *//* Returns: <none> *//* Effects: Creates an effect *//* *//****************************************************************/Effect::Effect(Time start_time, const XDString& symbol, Type kind) { start_time_ = start_time; symbol_ = symbol; kind_ = kind;}/****************************************************************//* *//* Function Name: Effect::Effect *//* Parameters: Effect& *//* Returns: <none> *//* Effects: copy constructor *//* *//****************************************************************/Effect::Effect(Effect& effect){ start_time_ = effect.start_time_; symbol_ = effect.symbol_; kind_ = effect.kind_;}/****************************************************************//* *//* Function Name: Effect::operator= *//* Parameters: *//* Effect& : the effect to be assigned from *//* Returns: the this pointer *//* Effects: *//* copies effect to this, by over writing the current *//* effect data. *//****************************************************************/Effect& Effect::operator=(Effect& effect) { start_time_ = effect.start_time_; symbol_ = effect.symbol_; kind_ = effect.kind_; return *this;}int EffectCompare::equal(Effect* effect, Effect* to){ if(effect->start_time_ == to->start_time_) { return 1; }else return 0;}int EffectCompare::compare(Effect* effect, Effect* to){ return 0;}Event::Event(Time start_time, XDString type) : Effect(start_time, type, Effect::EVENT){}Event::~Event(){;}Event::Event(Event& event) : Effect((Effect&) event){;}Event& Event::operator=(Event& event){ (Effect&) *this = Effect::operator=((Effect&) event); return *this;}int EventCompare::equal(Event* event, Event* to){ if(event->getType() == to->getType()) { return 1; } else return 0;}int EventCompare::compare(Event* event, Event* to){ if(event->starttime() < to->starttime()) { return 1; } else return 0;}/****************************************************************//* *//* Function Name: Fact::Fact *//* Parameters: *//* Time start_time: when the fact begins *//* const XDString& type : the symbol for the fact *//* int negate : wether it is a negation or not *//* Time end_time : when it ends *//* Returns: <none> *//* Effects: Creates a Fact. *//* *//****************************************************************/Fact::Fact(Time start_time, const XDString& type, int negate, Time end_time):Effect(start_time, type, Effect::FACT){ end_time_ = end_time; negation_ = negate;}/****************************************************************//* *//* Function Name:Fact::operator = *//* Parameters:Fact& fact : the fact to assign from *//* Returns: Fact&, *//* Effects: assignment operator *//* *//****************************************************************/Fact& Fact::operator=(Fact& fact){ // call the parent classes assignment operator (Effect&) *this = Effect::operator=((Effect&) fact); // modify your variables end_time_ = fact.end_time_; negation_ = fact.negation_; return *this;}/****************************************************************//* *//* Function Name: Fact::Fact *//* Parameters: Fact& *//* Returns: <none> *//* Effects: copy constructor *//* *//****************************************************************/Fact::Fact(Fact& fact) : Effect((Effect&) fact){ end_time_ = fact.end_time_; negation_ = fact.negation_; return;}/****************************************************************//* *//* Function Name: negate *//* Parameters: <none> *//* Returns: <none> *//* Effects: negates the current fact *//* *//****************************************************************/void Fact::negate(){ negation_ *= -1;}/****************************************************************//* *//* Function Name: Fact::isTrue *//* Parameters: *//* Fact* fact : the fact being compared to *//* Time tiem : the current time *//* Returns: *//* 1 for true *//* 0 for false *//* Effects: *//* Determines wether a fact is true if the this->fact is *//* the same fact and time is between the starttime and *//* endTime of this->fact *//****************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -