/** * Aquarium Lab Series * Copyright (C) 2000 Alyce Brady * * Implementation file for Aquarium class -- see aquarium.h for details. * * License: * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include "aquarium.h" #include "randgen.h" // constructors Aquarium::Aquarium() : myWidth(0), myHeight(0) // postcondition: width and height are initialized to 0 { } Aquarium::Aquarium(int width, int height) : myWidth(width), myHeight(height) // postcondition: Width() == width, Height() == height { } // public observer functions int Aquarium::Width() const // returns width of aquarium { return myWidth; } int Aquarium::Height() const // returns height of aquarium { return myHeight; } bool Aquarium::ValidLoc(int x_coord, int y_coord) const // returns true if and only x_coord and y_coord // represent a valid location in the aquarium { return (0 <= x_coord and x_coord < myWidth) and (0 <= y_coord and y_coord < myHeight); } int Aquarium::LeftWallLoc() const // returns the x coordinate of the aquarium's left wall { return -1; } int Aquarium::RightWallLoc() const // returns the x coordinate of the aquarium's right wall { return myWidth; }