diff --git a/Fruits.cpp b/Fruits.cpp new file mode 100644 index 0000000..ea90664 --- /dev/null +++ b/Fruits.cpp @@ -0,0 +1,27 @@ +#include +#include +#include "Fruits.h" +using namespace std; + +Fruits::Fruits(string fruitName) +: name{fruitName} +{ + +} +int Fruits::getNumFruits() +{ + return numFruits; +} +void Fruits::setNumFruits() +{ + cout << "How many " << getName() << " are there?\n"; + cin >> numFruits; +} +void Fruits::setName(string fruitName) +{ + name = fruitName; +} +string Fruits::getName() +{ + return name; +} diff --git a/Fruits.h b/Fruits.h new file mode 100644 index 0000000..4db95ed --- /dev/null +++ b/Fruits.h @@ -0,0 +1,16 @@ +#ifndef FRUITS_H +#define FRUITS_H + +class Fruits +{ +public: + explicit Fruits(std::string fruitName); + int getNumFruits(); + void setNumFruits(); + void setName(std::string fruitName); + std::string getName(); +private: + int numFruits; + std::string name; +}; +#endif diff --git a/hellogit b/hellogit new file mode 100755 index 0000000..f3e421e Binary files /dev/null and b/hellogit differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..59c61dd --- /dev/null +++ b/main.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "Fruits.h" +using namespace std; + +int main () +{ + vector myVector; + Fruits fruit1{"oranges"}; + Fruits fruit2{"bananas"}; + Fruits fruit3{"apples"}; + Fruits fruit4{"mangoes"}; + fruit1.setNumFruits(); + myVector.push_back(fruit1.getNumFruits()); + fruit2.setNumFruits(); + myVector.push_back(fruit2.getNumFruits()); + fruit3.setNumFruits(); + myVector.push_back(fruit3.getNumFruits()); + fruit4.setNumFruits(); + myVector.push_back(fruit4.getNumFruits()); + cout << "Fruits will be taken out\n"; + myVector.pop_back(); + myVector.pop_back(); + myVector.pop_back(); + cout << "How many fruits are there now?\n"; + for(int x=0; x