Polluter.h

/*

Programmer: Jennifer Leopold

Date: November 10, 2016

File: polluter.h

Purpose: This file contains the definition of a Polluter class.

*/

#ifndef POLLUTER_H

#define POLLUTER_H

#include<iostream>

#include "town.h"

#include "point.h"

using namespace std;

// Default symbol (char) for polluter on grid

const char DEFAULT_POLLUTER_SYMBOL = 'P';

// Default init location

const int INIT_POLLUTER_LOC_X = -1;

const int INIT_POLLUTER_LOC_Y = -1;

class Polluter

{

private:

// Member var's for polluter's location (on grid),

// symbol (displayed on grid), and name

Point m_location;

char m_symbol;

string m_name;

public:

// Parameterized constructor for Polluter.

// Preconditions: name should have a value.

// Postconditions: m_symbol set to DEFAULT_POLLUTER_SYMBOL

// and m_location set to Point with x and y coordinates

// INIT_POLLUTER_LOC_X and INIT_POLLUTER_LOC_Y,

// respectively.

Polluter(const string name) :

m_location(Point(INIT_POLLUTER_LOC_X,

INIT_POLLUTER_LOC_Y)),

m_symbol(DEFAULT_POLLUTER_SYMBOL), m_name(name) { }

// Mutator for m_location.

// Preconditions: p has values for its x and y coordinates.

// Postconditions: m_location's x and y coordinates have

// been set to those of p.

void setLocation(const Point &p)

{

m_location = p;

return;

}

// Choose a random location to place this Polluter that is

// not "on top" of anything else.

// Preconditions: None.

// Postconditions: A randomly chosen position of the town's

// grid now contains this Polluter's m_symbol, and this

// Polluter's m_location is now the randomly chosen

// position.

void placeMe(Town& town);

// Take a step in a random direction in the specified

// town (without "stepping on anything").

// Preconditions: None.

// Postconditions: A randomly chosen position of the town's

// grid now contains this Polluter's m_symbol, and this

// Polluter's m_location is now the randomly chosen

// position.

void randMove(Town &town);

};

#endif