// Tara Joshi
// Proj 3: simft, fish.cpp
// 23 April 2019
#include <iostream>
#include "fishtank.h"
using namespace std;
bool Fish :: read_fish(istream &input) {
string line;
string input1;
getline (input, line);
stringstream ss(line);
ss >> input1 >> height >> width >> start_row >> start_col >> vert_speed
>> hor_speed >> lifetime >> name;
for (int i = 0; i < height; i++){
input.ignore();
getline (input, line);
for (int j = 0; i < width; j++){
data[i][j] = line[j];
}
}
}
// Tara Joshi
// Proj 3: simft, fishtank.cpp
// April 17, 2019
#include <iostream>
using namespace std;
#include "fishtank.h"
/*
purpose: makes height, row, width, and column 0, fills tank
picture with blanks
parameter: NA
return value: NA
*/
FishTank::FishTank()
{
height = 0;
width = 0;
row_num = 0;
col_num = 0;
symbol = ' ';
for(int i = 0; i < MAX_HGT; i++)
{
for (int j = 0; j < MAX_WID; j++)
{
tank_space[i][j] = ' ';
}
}
}
/*
purpose: makes the hieght and width the given values and behaves
like an empty constructor
parameter: int hgt, int wid
return value: NA
*/
FishTank::FishTank(int hgt, int wid)
{
height = hgt;
width = wid;
for(int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
tank_space[i][j] = ' ';
}
}
}
/*
purpose: sets height variable and returns true if its less than
or equal to the max height (50), otherwise it returns false
parameter: int hgt
return value: true or false
*/
bool FishTank::set_height(int hgt)
{
if (height > 50) {
return false;
} else {
hgt = height;
return true;
}
}
/*
purpose: sets the width of the variable
parameter: int wid
return value: returns true if its less than or equal to
the max width (200), otherwise it returns false
*/
bool FishTank::set_width(int wid)
{
if (width > 200) {
return false;
} else {
wid = width;
return true;
}
}
/*
purpose: elicits height of the tank
parameter: NA
return value: int height
*/
int FishTank::get_height()
{
return height;
}
/*
purpose: elicits width of tank
parameter: NA
return value: int width
*/
int FishTank::get_width()
{
return width;
}
/*
purpose: this function clears the tank and fills it with
empty spaces
parameter: NA
return value: NA
*/
void FishTank::clear_tank()
{
for(int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
tank_space[i][j] = ' ';
}
}
}
/*
purpose: checks to see if the row and col inputed are valid,
then if they are, updates the character map at the specific row
and column with inputed character.
parameter: int row, int col, char c
return value: NA
*/
void FishTank::update_at(int row, int col, char c)
{
row_num = row;
col_num = col;
symbol = c;
if ((row <= height) && (col <= width)) {
tank_space[row][col] = c;
}
}
/*
purpose: prints character map in terminal
parameter: NA
return value: NA
*/
void FishTank::show_tank()
{
for(int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
cout << tank_space[i][j] << endl;
}
}
}
// Tara Joshi
// Proj 3: simft, fishtank.h
// April 17, 2019
#include <iostream>
#ifndef FISHTANK_H
#define FISHTANK_H
using namespace std;
class FishTank
{
private:
static const int MAX_HGT = 50;
static const int MAX_MID = 200;
int row_num;
int col_num;
char symbol;
int width;
int height;
public:
FishTank();
FishTank(int hgt, int wid);
bool set_height(int hgt);
bool set_width();
void clear_tank();
void update_at(int row, int col, char c);
void show_tank();
};
#endif
// Tara Joshi
// Proj 3: simft, simulation.h
// April 17, 2019
#include <iostream>
#ifndef SIMULATION_H
#define SIMULATION_H
#include "fishtank.h"
using namespace std;
class Simulation
{
private:
struct fish_tank;
public:
simulation();
bool setup(string filename);
void run(bool single_step, int fps);
};
#endif
// Tara Joshi v
// Proj 3: simft, simft.cpp
// April 17, 2019
#include <iostream>
#include "fishtank.h"
using namespace std;
int main ()
{
// testing update at and show tank
FishTank tank (30, 21);
tank.update_at (4, 9,'&');
tank.show_tank();
// testing max parameters
FishTank tank2 (50, 200);
tank.update_at (4, 9,'&');
tank.show_tank();
// testing get height
cout << tank.get_height();
// testing get width
cout << tank.get_width();
return 0;
}