Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chelseamariehicks committed Mar 2, 2019
1 parent ac03264 commit d840b78
Show file tree
Hide file tree
Showing 12 changed files with 1,189 additions and 0 deletions.
79 changes: 79 additions & 0 deletions Animal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*************************************************************************
** Author: Chelsea Hicks
** Date: 2/3/19
** Description: The source code file for the Animal parent class, which
** defines the getter and setter functions to be inherited
** by the child classes Penguin, Tiger, and Turtle.
*************************************************************************/

#include <iostream>
#include "Animal.hpp"

using std::cout;
using std::cin;
using std::endl;


//Default constructor -- declared but never defined
Animal::Animal()
{

}

//Setter and getter functions for the age of an animal
void Animal::setAge(int ageIn)
{
age = ageIn;
}

int Animal::getAge()
{
return age;
}

//Setter and getter functions for the cost of an animal
void Animal::setCost(float costIn)
{
cost = costIn;
}

float Animal::getCost()
{
return cost;
}

//Setter and getter functions for the number of babies an animal has
void Animal::setBabies(int babiesIn)
{
babies = babiesIn;
}

int Animal::getBabies()
{
return babies;
}


//Setter and getter functions for the food cost of an animal
//Base food price is $10
void Animal::setFoodCost(float multiplier)
{
foodCost = BASE_FOOD_COST * multiplier;
}

float Animal::getFoodCost()
{
return foodCost;
}

//Setter and getter functions for the payoff per day of an animal
void Animal::setPayoff(float payoffIn)
{
payoff = payoffIn;
}

float Animal::getPayoff()
{
return payoff;
}

34 changes: 34 additions & 0 deletions Animal.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*************************************************************************
** Author: Chelsea Hicks
** Date: 2/3/19
** Description: The header file for the Animal parent class, which
** declares protected member variables and getter and
** setter functions to be inherited by the child classes
** Penguin, Tiger, and Turtle.
*************************************************************************/

#ifndef ANIMAL_HPP
#define ANIMAL_HPP

class Animal
{
protected:
int age, babies;
float cost, foodCost, payoff;
const int BASE_FOOD_COST = 20;

public:
Animal(); //Default constructor
void setAge(int);
int getAge();
void setCost(float);
float getCost();
void setBabies(int);
int getBabies();
void setFoodCost(float);
float getFoodCost();
void setPayoff(float);
float getPayoff();
};

#endif
24 changes: 24 additions & 0 deletions Penguin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*************************************************************************
** Author: Chelsea Hicks
** Date: 2/3/19
** Description: The source code file for the Penguin child class, which
** defines the constructor using setter functions from
** the parent class Animal.
*************************************************************************/

#include <iostream>
#include "Penguin.hpp"

using std::cout;
using std::cin;
using std::endl;

//Default constructor for creating a penguin object
Penguin::Penguin()
{
setAge(1);
setCost(1000);
setBabies(5);
setFoodCost(1);
setPayoff(100);
}
21 changes: 21 additions & 0 deletions Penguin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*************************************************************************
** Author: Chelsea Hicks
** Date: 2/3/19
** Description: The header file for the Penguin child class, which
** declares a constructor for a penguin object.
*************************************************************************/

#ifndef PENGUIN_HPP
#define PENGUIN_HPP

#include "Animal.hpp"

class Penguin : public Animal
{
private:

public:
Penguin(); //Default constructor
};

#endif
24 changes: 24 additions & 0 deletions Tiger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*************************************************************************
** Author: Chelsea Hicks
** Date: 2/3/19
** Description: The source code file for the Tiger child class, which
** defines the constructor using setter functions from
** the parent class Animal.
*************************************************************************/

#include <iostream>
#include "Tiger.hpp"

using std::cout;
using std::cin;
using std::endl;

//Default constructor for creating a tiger object
Tiger::Tiger()
{
setAge(1);
setCost(10000);
setBabies(1);
setFoodCost(5);
setPayoff(2000);
}
21 changes: 21 additions & 0 deletions Tiger.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*************************************************************************
** Author: Chelsea Hicks
** Date: 2/3/19
** Description: The header file for the Tiger child class, which
** declares a constructor for a tiger object.
*************************************************************************/

#ifndef TIGER_HPP
#define TIGER_HPP

#include "Animal.hpp"

class Tiger : public Animal
{
private:

public:
Tiger(); //Default constructor
};

#endif
24 changes: 24 additions & 0 deletions Turtle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*************************************************************************
** Author: Chelsea Hicks
** Date: 2/3/19
** Description: The source code file for the Turtle child class, which
** defines the constructor using setter functions from
** the parent class Animal.
*************************************************************************/

#include <iostream>
#include "Turtle.hpp"

using std::cout;
using std::cin;
using std::endl;

//Default constructor for creating a turtle object
Turtle::Turtle()
{
setAge(1);
setCost(100);
setBabies(10);
setFoodCost(0.5);
setPayoff(5);
}
21 changes: 21 additions & 0 deletions Turtle.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*************************************************************************
** Author: Chelsea Hicks
** Date: 2/3/19
** Description: The header file for the Turtle child class, which
** declares a constructor for a turtle object.
*************************************************************************/

#ifndef TURTLE_HPP
#define TURTLE_HPP

#include "Animal.hpp"

class Turtle : public Animal
{
private:

public:
Turtle(); //Default constructor
};

#endif
Loading

0 comments on commit d840b78

Please sign in to comment.