-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac03264
commit d840b78
Showing
12 changed files
with
1,189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.