Please send questions to
st10@humboldt.edu .
/*--------------------------------------------------
created by smtuttle at Fri Oct 22 08:52:21 PDT 2010
--------------------------------------------------*/
#include <iostream>
#include <cmath>
#include "boa.h"
using namespace std;
/*--------------------------------------------------
Contract: boa_test : void -> bool
Purpose: expects nothing, and produces whether boa's
selectors return what is expected for an example boa
Examples: boa_test( ) == true
--------------------------------------------------*/
bool boa_test( )
{
// first: exercise each constructor by creating a local
// (usually static) instance of your new class
// this is a local boa object -- a local instance of the
// boa class -- whose scope, or meaning, is JUST the
// function body it is declared in
boa george("fuschia", 50, "crocodiles");
// test all constructors!
// C++ SYNTAX EXCEPTION: when you declare a
// variable using a zero-argument constructor,
// you DON'T put parentheses after the variable
// name!! (so it won't look like a function
// header to the C++ compiler...)
boa carol;
// these are to keep track of my test results
bool selector_results;
bool modif_results;
selector_results =
(george.get_color() == "fuschia") and
(george.get_length() == 50) and
(george.get_food() == "crocodiles") and
(carol.get_color() == "green") and
(carol.get_length() == 6) and
(carol.get_food() == "alligators");
// exercise the modifier methods
george.set_color("purple");
george.set_length(75);
george.set_food("dragons");
modif_results =
(george.get_color() == "purple") and
(george.get_length() == 75) and
(george.get_food() == "dragons");
return (selector_results and modif_results);
}