//****************************************************************// // // // Copyright (c) 1997. // // Dr. Michael A. Redmond // // // // This software may not be distributed further without permission from // // Dr Michael A. Redmond. // // // // This software is distributed WITHOUT ANY WARRANTY. No claims are made // // as to its functionality or purpose. // // // // Title: Tw_Color.h // Use: Provides abstraction for the color of pegs and links // for twixt // Author: Dr Michael A. Redmond // // Date: 3/05/97 // // // // //**************************************************************************// // tw-color.h: declaration of Tw_Color ADT // conditional compilation to avoid trying to include same thing twice #ifndef TW_COLOR_H #define TW_COLOR_H #include enum color {empty, black, white, illegal}; const color badcolor = illegal; // Tw_Color ADT: class description // Defines class and its interface to the world // implementation is in tw-color.cpp class Tw_Color { // public interface can be used by anybody public: // member functions // constructor - color defaults to empty Tw_Color(color col = empty); // inspectors color GetColor() const; color GetRevColor() const; // returns a one char abreviation for the color // like insert but returns the char instead of putting it in // the output stream char GetCharRep() const; // mutators - establish new values of attributes (data members) void SetColor(color col); void RevColor(); // facilitators // some stream facilitators // write to stream void Insert(ostream &sout) const; // read from stream void Extract(istream &sin); protected: // inspectors // mutators // facilitators private: // data members color colorv; }; // below overloads standard c++ operators so that they can be used // with tw_color class objects, so syntax is like with ints floats etc // // Tw_Color ADT: auxiliary operator description ostream& operator<<(ostream &sout, const Tw_Color &s); istream& operator>>(istream &sin, Tw_Color &r); bool operator==(const Tw_Color &left, const Tw_Color &right); bool operator!=(const Tw_Color &left, const Tw_Color &right); bool operator!=(const Tw_Color &left, const color &right); #endif