From 514c497ad25e152b696cc74d2dde97f2fdc0b056 Mon Sep 17 00:00:00 2001 From: Owl <40027596+tkim949@users.noreply.github.com> Date: Sun, 27 Jan 2019 12:14:01 -0800 Subject: [PATCH 1/5] edits more --- Zoo.cpp | 410 -------------------------------------------------------- 1 file changed, 410 deletions(-) delete mode 100644 Zoo.cpp diff --git a/Zoo.cpp b/Zoo.cpp deleted file mode 100644 index 5e11cba..0000000 --- a/Zoo.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/**************************************************************************************************** - * * Program name: CS162 Project2 - * * Author: Taekyoung Kim - * * Date: 01/21/2019 - * * Description: This is Zoo.cpp file for CS162 Project2 - * * This project shows a zoo that has a few animals. We needs inheritance and class...... - ******************************************************************************************************/ - -#include "Zoo.h" -#include "Animal.h" -#include "inputVal.h" -#include -#include -#include "Tiger.h" -#include "Penguin.h" -#include "Turtle.h" -#include "DArray.h" -#include - -Zoo::Zoo()=default; -Zoo::~Zoo()=default; - -/********************************** -int Zoo::getDay(){ - return this -> day; -} -void Zoo::setDay(int d){ - day = d; -} -int Zoo::getNumOfTig(){ - return numOfTig; -} -void Zoo::setNumOfTig(int tig){ - numOfTig =tig; - -} -int Zoo::getNumOfPeng(){ - return numOfPeng; - -} -void Zoo::setNumOfPeng(int pen){ - numOfPeng = pen; - -} -int Zoo::getNumOfTurt(){ - return numOfTurt; - -} -void Zoo::setNumOfTurt(int turt){ - numOfTurt =turt; -} -************************************************/ -void Zoo::play(){ - - std::cout<<"Welcome to the Zoo! Now you run this Fantastic Zoo."<> fBuyTi; - numOfTig = inputVal(fBuyTi); - - if(!(numOfTig==1 || numOfTig ==2)) { - - do{ - std::cin.clear(); - std::cin.ignore(INT_MAX, '\n'); - std::cout<<"Wrong input. You can buy only 1 or 2 Tigers, Please try again: "; - std::cin >> fBuyTi; - numOfTig = inputVal(fBuyTi); - }while(!(numOfTig ==1 || numOfTig==2)); - } - - for(int i =0; i > fBuyP; - numOfPeng = inputVal(fBuyP); - - if(!(numOfPeng ==1 || numOfPeng ==2)) { - - do{ - std::cin.clear(); - std::cin.ignore(INT_MAX, '\n'); - std::cout<<"Wrong input. You can buy only 1 or 2 Penguins, Please try again: "; - std::cin >> fBuyP; - numOfPeng = inputVal(fBuyP); - }while(!(numOfPeng ==1 || numOfPeng ==2)); - } - - for(int i =0; i >fBuyTu; - numOfTurt = inputVal(fBuyTu); - - if(!(numOfTurt ==1 || numOfTurt ==2)) { - - do{ - std::cin.clear(); - std::cin.ignore(INT_MAX, '\n'); - std::cout<<"Wrong input. You can buy only 1 or 2 Turtles, Please try again: "; - std::cin>>fBuyTu; - numOfTurt = inputVal(fBuyTu); - - }while(!(numOfTurt ==1 || numOfTurt ==2)); - } - - for(int i =0; i dist(1, 3); - event = dist(mt); - - std::cout<<"Today's event is: "< dist3(250, 500); - bonus= dist3(mt); - std::cout<<"Your today bonus is "<>buyNewOne; - buyNew =inputVal(buyNewOne); - - if(!(buyNew ==1 || buyNew ==2)) { - - do{ - std::cin.clear(); - std::cin.ignore(INT_MAX, '\n'); - std::cout<<"Wrong input. You can only input 1 or 2, Please try again: "; - std::cin>>buyNewOne; - buyNew =inputVal(buyNewOne); - }while(!(buyNew ==1 || buyNew ==2)); - } - - if(buyNew==1) { - - double buyChoice; - int buyOneMore; - std::cout - << "So, you want to buy. Good! which animal will you buy; input 1 for Tiger, 2 for Penguin, and 3 for Turtle: "; - std::cin >> buyChoice; - buyOneMore = inputVal(buyChoice); - - if(!(buyOneMore ==1 || buyOneMore ==2 || buyOneMore ==3)) { - - do{ - std::cin.clear(); - std::cin.ignore(INT_MAX, '\n'); - std::cout<<"Wrong input. You should input 1,2,or 3. Please try again: "; - std::cin >> buyChoice; - buyOneMore = inputVal(buyChoice); - - }while(!(buyOneMore ==1 || buyOneMore ==2 || buyOneMore ==3)); - } - - if (buyOneMore == 1) { - - std::cout << "So, you decided to buy a Tiger. Best Choice!" << std::endl; - if(numOfTig >= room.getRoomOfTi()) { - - room.arrayTiger(arrayOfTi, room.getRoomOfTi()); - - } - //Adds a new tiger to the array. - arrayOfTi[numOfTig] = Tiger(3, tiger.getCost(), 0, tiger.getBaseFoodCost(), tiger.getPayoff()); - numOfTig +=1; - account -= tiger.getCost(); - std::cout<<"After you buy the tiger, your balance is "<= room.getRoomOfPe()) { - - room.arrayPen(arrayOfPe, room.getRoomOfPe()); - - } - arrayOfPe[numOfPeng] = Penguin(3, penguin.getCost(), 0, penguin.getBaseFoodCost(), penguin.getPayoff()); - numOfPeng+=1; - account -= penguin.getCost(); - std::cout<<"After you buy the penguin, your balance is "<= room.getRoomOfTu()) { - - room.arrayTur(arrayOfTur, room.getRoomOfTu()); - - } - arrayOfTur[numOfTurt] = Turtle(3, turtle.getCost(), 0, turtle.getBaseFoodCost(), turtle.getPayoff()); - numOfTurt+=1; - account -= turtle.getCost(); - std::cout<<"After you buy the turtle, your balance is "<>playAgain; - std::cout< 0); - - if (account < 0){ - std::cout<<"I'm sorry, but your account is empty. Play next time. Good buy!"< Date: Sun, 27 Jan 2019 12:14:23 -0800 Subject: [PATCH 2/5] Delete DArray.cpp --- DArray.cpp | 451 ----------------------------------------------------- 1 file changed, 451 deletions(-) delete mode 100644 DArray.cpp diff --git a/DArray.cpp b/DArray.cpp deleted file mode 100644 index 751e76e..0000000 --- a/DArray.cpp +++ /dev/null @@ -1,451 +0,0 @@ -/**************************************************************************************************** - * * Program name: CS162 Project2 - * * Author: Taekyoung Kim - * * Date: 01/21/2019 - * * Description: This is Zoo.cpp file for CS162 Project2 - * * This project shows a zoo that has a few animals. We needs inheritance and class...... - ******************************************************************************************************/ - - -#include "DArray.h" -#include "Zoo.h" -#include "Animal.h" -#include "Penguin.h" -#include "Turtle.h" -#include "Tiger.h" -#include -#include - - -DArray::DArray() =default; -DArray::~DArray()=default; - -int DArray::getRoomOfTi(){ - return roomOfTi; - -} -void DArray::setRoomOfTi(int ti){ - roomOfTi = ti; - -} -int DArray::getRoomOfPe(){ - return roomOfPe; -} -void DArray::setRoomOfPe(int pe){ - roomOfPe = pe; - -} -int DArray::getRoomOfTu(){ - return roomOfTu; - -} -void DArray::setRoomOfTu(int tu){ - roomOfTu = tu; - -} - -void DArray::arrayTiger(Animal *arr, int roomOfTi){ -//void DArray::arrayTiger(Tiger *arr, int roomOfTi){ - - //Tiger *temp_ti = new Tiger[roomOfTi * 2]; - Animal *temp_ti = new Tiger[roomOfTi * 2]; - - for (int i = 0; i < roomOfTi * 2; i++) { - temp_ti[i] = Tiger(0, 0.00, 0, 0.00, 0.00); - } - - for (int i = 0; i < roomOfTi; i++) { - temp_ti[i] = arr[i]; - } - //delete[] arr; - //delete arr; - setRoomOfTi(roomOfTi*2); - // - for (int i = 0; i < roomOfTi * 2; i++) { - arr[i] = Tiger(0, 0.00, 0, 0.00, 0.00); - } - - arr = temp_ti; - -} - -void DArray::arrayPen(Animal *arra, int roomOfPe){ -//void DArray::arrayPen(Penguin *arra, int roomOfPe){ - - - //Penguin *temp_pe = new Penguin[roomOfPe * 2]; - Animal *temp_pe = new Penguin[roomOfPe * 2]; - - for (int i = 0; i < roomOfPe * 2; i++) { - temp_pe[i] = Penguin(0, 0.00, 0, 0.00, 0.00); - } - - for (int i = 0; i < roomOfPe; i++) { - temp_pe[i] = arra[i]; - } - //issue occur point! - //delete [] arra; - //delete arra; - setRoomOfPe(roomOfPe*2); - - for (int i = roomOfPe; i < roomOfPe * 2; i++) { - arra[i] = Penguin(0, 0.00, 0, 0.00, 0.00); - } - - arra = temp_pe; - -} - -void DArray::arrayTur(Animal *array, int roomOfTu){ -//void DArray::arrayTur(Turtle *array, int roomOfTu){ - - //Turtle *temp_tu = new Turtle[roomOfTu * 2]; - Animal *temp_tu = new Turtle[roomOfTu * 2]; - - for (int i = 0; i < roomOfTu * 2; i++) { - temp_tu[i] = Turtle(0, 0.00, 0, 0.00, 0.00); - } - - for (int i = 0; i < roomOfTu; i++) { - temp_tu[i] = array[i]; - } - //delete [] array; - //delete array; - setRoomOfTu(roomOfTu*2); - - for (int i = roomOfTu; i < roomOfTu * 2; i++) { - array[i] = Turtle(0, 0.00, 0, 0.00, 0.00); - } - - array = temp_tu; - -} - -void DArray::pickRemove(int &ti, int &pe, int &tu, Animal *arr, Animal *arra, Animal *array) { -//void DArray::pickRemove(int &ti, int &pe, int &tu, Tiger *arr, Penguin *arra, Turtle *array) { - - - Zoo nyc; - - int numOfAni = ti + pe + tu; - - std::cout << "Tiger num " << ti << " "; - std::cout << "Penguin num " << pe << " "; - std::cout << "Turtle num " << tu << " " << std::endl; - - int whoSick; - - int *allAnimal = new int[numOfAni]; - - for (int i = 0; i < ti; i++) { - - allAnimal[i] = i; - } - for (int i = ti; i < ti + pe; i++) { - - allAnimal[i] = i; - } - for (int i = ti + pe; i < numOfAni; i++) { - - allAnimal[i] = i; - } - - if (numOfAni <= 0) { - std::cout<<"I don't know how to say in this case, But you don't have any animal.so no animal dies."<0 - - std::cout<<"The Turtle is (before a penguin is picked to be sick.): "< dist2(1, numOfAni); - whoSick = dist2(mt) - 1; - - std::cout << "Who sick? number is: " << whoSick + 1 << std::endl; - - // A Tiger gets sick and remove - if (whoSick < ti) { - - std::cout << "Your Tiger number " << whoSick + 1 << " got sick and died. So sorry!" << std::endl; - ti -= 1; - //nyc.setNumOfTig(ti); - - for (int j = whoSick; j < roomOfTi; j++) { - - //Tiger temp = arr[j]; - Animal temp = arr[j]; - //temp = arra[j]; - arr[j] = arr[j + 1]; - arr[j + 1] = temp; - } - arr[roomOfTi - 1] = Tiger(0, 0.00, 0, 0.00, 0.00); - delete[] allAnimal; - // allAnimal = 0; - } - //A Penguin get sick and remove - else if (whoSick >= ti && whoSick < ti + pe) { - - pe -= 1; - int sickP = whoSick - ti; - - std::cout << "Your Penguin number " << sickP + 1 << " got sick and died. So sorry" << std::endl; - - for (int j = sickP; j < roomOfPe; j++) { - - - //Penguin temp = arra[j]; - Animal temp = arra[j]; - // temp = arra[j]; - arra[j] = arra[j + 1]; - arra[j + 1] = temp; - } - arra[roomOfPe - 1] = Penguin(0, 0.00, 0, 0.00, 0.00); - - //Check turtle! - std::cout<<"The Turtle is (after the penguin die): "<= numOfTi+numOfPe && whoSick < numOfAni - { - tu -= 1; - - int sickTu = whoSick - (ti + pe); - std::cout << "Your Turtle number " << sickTu + 1 << " got sick and died. So sorry" << std::endl; - - - for (int j = sickTu; j < roomOfTu; j++) { - - //Turtle temp = array[j]; - Animal temp = array[j]; - // temp = array[j]; - array[j] = array[j + 1]; - array[j + 1] = temp; - } - array[roomOfTu - 1] = Turtle(0, 0.00, 0, 0.00, 0.00); - - delete[] allAnimal; - // allAnimal = 0; - } - - } - -} -void DArray::whoHasBaby(int &numTi, int &numPen, int &numTurt, Animal *arr, Animal *arra, Animal *array){ -//void DArray::whoHasBaby(int &numTi, int &numPen, int &numTurt, Tiger *arr, Penguin *arra, Turtle *array){ -//void whoHasBaby(Tiger *arr, Penguin *arra, Turtle *array) { - Zoo zoo; - int draw; - - int numAdTi = 0; - for (int i = 0; i < numTi; i++) { - - if (arr[i].getAge() >= 3) { - numAdTi += 1; - } - } - std::cout <<"Number of Adult Tigers: " << numAdTi << std::endl; - - int *adultTiger = new int[numAdTi]; - - int j = 0; - for (int i = 0; i < numTi; i++) { - if (arr[i].getAge() >= 3) { - adultTiger[j] = i; - j++; - } - } - - int numAdPen = 0; - for (int i = 0; i < numPen; i++) { - if (arra[i].getAge() >= 3) { - numAdPen += 1; - } - } - std::cout <<"Number of Adult penguins: " << numAdPen << std::endl; - - int *adultPenguin = new int[numAdPen]; - - int k = 0; - for (int i = 0; i < numPen; i++) { - if (arra[i].getAge() >= 3) { - adultPenguin[k] = i; - k++; - } - } - - int numAdTur = 0; - for (int i = 0; i < numTurt; i++) { - if (array[i].getAge() >= 3) { - numAdTur += 1; - } - std::cout<<"Age of Turtles: "<= 3) { - adultTurtle[l] = i; - l++; - } - } - - //to just show an check - std::cout<<"Your Adult penguin: "; - for (int m = 0; m < numAdPen; m++) { - - std::cout << "number " << adultPenguin[m]+1 <<" , "; - } - - int numAdAnimal = numAdTi + numAdPen + numAdTur; - - std::random_device ran1; - std::mt19937 mt1(ran1()); - std::uniform_int_distribution dist(1, numAdAnimal); - draw = dist(mt1)-1; - - - if (numAdAnimal <= 0) { - std::cout << "Sorry. You don't have any adult animals. Maybe next time!" << std::endl; - - delete[] adultTiger; - //adultTiger =0; - delete[] adultPenguin; - //adultPenguin =0; - delete[] adultTurtle; - // adultTurtle =0; - } - - - else { - //A Tiger has a baby. - if (draw < numAdTi) { - //Tiger ti; - //ti.cost; - //std::cout<<"Tiger cost inside whohasbaby fuct"<= roomOfTi) { - - this->DArray::arrayTiger(arr, roomOfTi); - - std::cout<<"Room For Tiger after resizing "<< roomOfTi<= numAdTi && draw < numAdTi + numAdPen) { - //Penguin pe; - //Animal *peng = new Penguin(); - // peng->getCost(); - int chosenPen; - chosenPen = adultPenguin[draw - numAdTi]; - std::cout << "Your penguin number "<= roomOfPe) { - - //issue occur point! - arrayPen(arra, roomOfPe); - std::cout<<"Room For penguin after resizing "<= numOfTi+numOfPe && whoSick < numOfAni - { - - int chosenTurtle; - chosenTurtle = adultTurtle[draw - numAdTi - numAdPen]; - std::cout << "Your Turtle number "<= roomOfTu) { - - arrayTur(array, roomOfTu); - std::cout<<"Room For Turtle after resizing "< Date: Sun, 27 Jan 2019 12:14:32 -0800 Subject: [PATCH 3/5] Delete DArray.h --- DArray.h | 56 -------------------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 DArray.h diff --git a/DArray.h b/DArray.h deleted file mode 100644 index e023a24..0000000 --- a/DArray.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************************************** - * * Program name: CS162 Project2 - * * Author: Taekyoung Kim - * * Date: 01/21/2019 - * * Description: This is Zoo.cpp file for CS162 Project2 - * * This project shows a zoo that has a few animals. We needs inheritance and class...... - ******************************************************************************************************/ - - -#ifndef PROJECT2_DARRAY_H -#define PROJECT2_DARRAY_H -#include "Turtle.h" -#include "Animal.h" -#include "Penguin.h" -#include "Tiger.h" - - -class DArray { - -protected: - - int roomOfTi; - int roomOfPe; - int roomOfTu; - - Tiger *arr; - Penguin *arra; - Turtle *array; - -public: - DArray(); - ~DArray(); - int getRoomOfTi(); - void setRoomOfTi(int ti); - int getRoomOfPe(); - void setRoomOfPe(int pe); - int getRoomOfTu(); - void setRoomOfTu(int tu); - /*************************************** - void arrayTiger(Tiger *arr, int sizeOfTi); - void arrayPen(Penguin *arra, int sizeOfPe); - void arrayTur(Turtle *array, int sizeOfTu); - void pickRemove(int &ti, int &pe, int &tu, Tiger *arr, Penguin *arra, Turtle *array); - void whoHasBaby(int &rTiger, int &rPenguin, int &rTurtle, Tiger *arr, Penguin *arra, Turtle *array); - ****************************************/ - - void arrayTiger(Animal *arr, int sizeOfTi); - void arrayPen(Animal *arra, int sizeOfPe); - void arrayTur(Animal *array, int sizeOfTu); - void pickRemove(int &ti, int &pe, int &tu, Animal *arr, Animal *arra, Animal *array); - void whoHasBaby(int &rTiger, int &rPenguin, int &rTurtle, Animal *arr, Animal *arra, Animal *array); - -}; - - -#endif //PROJECT2_DARRAY_H From 78c97c4062c68e3f46be9086aa5070198654fc19 Mon Sep 17 00:00:00 2001 From: Owl <40027596+tkim949@users.noreply.github.com> Date: Sun, 27 Jan 2019 12:14:46 -0800 Subject: [PATCH 4/5] Delete Zoo.h --- Zoo.h | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 Zoo.h diff --git a/Zoo.h b/Zoo.h deleted file mode 100644 index 0fb22b0..0000000 --- a/Zoo.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************************************** - * * Program name: CS162 Project2 - * * Author: Taekyoung Kim - * * Date: 01/21/2019 - * * Description: This is Zoo.h file for CS162 Project2 - * * This project shows a zoo that has a few animals. We needs inheritance and class...... - ******************************************************************************************************/ - -#ifndef PROJECT2_ZOO_H -#define PROJECT2_ZOO_H - - -class Zoo { - -protected: - - - //int day = 0; - int numOfTig =0; - int numOfPeng =0; - int numOfTurt =0; - - - -public: - Zoo(); - ~Zoo(); - - /************************* - int getDay(); - void setDay(int d); - int getNumOfTig(); - void setNumOfTig(int tig); - int getNumOfPeng(); - void setNumOfPeng(int pen); - int getNumOfTurt(); - void setNumOfTurt(int turt); - *******************************/ - void play(); - double baseCost = 10.00; - -}; - - -#endif //PROJECT2_ZOO_H From 4f15e51aed17a96cc70c8d5017d24012eb96d2e4 Mon Sep 17 00:00:00 2001 From: Owl <40027596+tkim949@users.noreply.github.com> Date: Sun, 27 Jan 2019 12:16:38 -0800 Subject: [PATCH 5/5] uploads 4 files --- DArray.cpp | 382 +++++++++++++++++++++++++++++++++++++++++ DArray.h | 49 ++++++ Zoo.cpp | 490 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Zoo.h | 42 +++++ 4 files changed, 963 insertions(+) create mode 100644 DArray.cpp create mode 100644 DArray.h create mode 100644 Zoo.cpp create mode 100644 Zoo.h diff --git a/DArray.cpp b/DArray.cpp new file mode 100644 index 0000000..a169e44 --- /dev/null +++ b/DArray.cpp @@ -0,0 +1,382 @@ +/**************************************************************************************************** + * * Program name: CS162 Project2 + * * Author: Taekyoung Kim + * * Date: 01/21/2019 + * * Description: This is Zoo.cpp file for CS162 Project2 + * * This project shows a zoo that has a few animals. We needs inheritance and class...... + ******************************************************************************************************/ + + +#include "DArray.h" +#include "Zoo.h" +#include "Animal.h" +#include "Penguin.h" +#include "Turtle.h" +#include "Tiger.h" +#include +#include + + +DArray::DArray() =default; +DArray::~DArray()=default; + +int DArray::getRoomOfTi(){ + return roomOfTi; + +} +void DArray::setRoomOfTi(int ti){ + roomOfTi = ti; + +} +int DArray::getRoomOfPe(){ + return roomOfPe; +} +void DArray::setRoomOfPe(int pe){ + roomOfPe = pe; + +} +int DArray::getRoomOfTu(){ + return roomOfTu; + +} +void DArray::setRoomOfTu(int tu){ + roomOfTu = tu; + +} + + +void DArray::arrayTiger(Tiger *arr, int roomOfTi){ + + Tiger *temp_ti = new Tiger[roomOfTi * 2]; + + for (int i = 0; i < roomOfTi * 2; i++) { + temp_ti[i] = Tiger(0, 0.00, 0, 0.00, 0.00); + } + + for (int i = 0; i < roomOfTi; i++) { + temp_ti[i] = arr[i]; + } + //delete[] arr; + + for (int i = 0; i < roomOfTi * 2; i++) { + arr[i] = Tiger(0, 0.00, 0, 0.00, 0.00); + } + arr = temp_ti; + setRoomOfTi(roomOfTi*2); +} + +void DArray::arrayPen(Penguin *arra, int roomOfPe){ + + Penguin *temp_pe = new Penguin[roomOfPe * 2]; + + for (int i = 0; i < roomOfPe * 2; i++) { + temp_pe[i] = Penguin(0, 0.00, 0, 0.00, 0.00); + } + + for (int i = 0; i < roomOfPe; i++) { + temp_pe[i] = arra[i]; + } + + //delete [] arra; + + for (int i = roomOfPe; i < roomOfPe * 2; i++) { + arra[i] = Penguin(0, 0.00, 0, 0.00, 0.00); + } + arra = temp_pe; + setRoomOfPe(roomOfPe*2); + +} + +void DArray::arrayTur(Turtle *array, int roomOfTu){ + + Turtle *temp_tu = new Turtle[roomOfTu * 2]; + + for (int i = 0; i < roomOfTu * 2; i++) { + temp_tu[i] = Turtle(0, 0.00, 0, 0.00, 0.00); + } + + for (int i = 0; i < roomOfTu; i++) { + temp_tu[i] = array[i]; + } + //delete [] array; + + for (int i = roomOfTu; i < roomOfTu * 2; i++) { + array[i] = Turtle(0, 0.00, 0, 0.00, 0.00); + } + + array = temp_tu; + setRoomOfTu(roomOfTu*2); +} + +void DArray::pickRemove(int &ti, int &pe, int &tu, Tiger *arr, Penguin *arra, Turtle *array) { + + int numOfAni = ti + pe + tu; + + std::cout <<"You have "<< ti << " tiger/s "<0 + + std::cout<<"The Turtle is (before a penguin is picked to be sick.): "< dist2(1, numOfAni); + whoSick = dist2(mt) - 1; + + std::cout << "Who sick? number is: " << whoSick + 1 << std::endl; + + // A Tiger gets sick and remove + if (whoSick < ti) { + + std::cout << "Your Tiger number " << whoSick + 1 << " got sick and died. So sorry!" << std::endl; + ti -= 1; + //nyc.setNumOfTig(ti); + + for (int j = whoSick; j < roomOfTi; j++) { + + Tiger temp = arr[j]; + arr[j] = arr[j + 1]; + arr[j + 1] = temp; + } + arr[roomOfTi - 1] = Tiger(0, 0.00, 0, 0.00, 0.00); + + } + //A Penguin get sick and remove + else if (whoSick >= ti && whoSick < ti + pe) { + + pe -= 1; + int sickP = whoSick - ti; + + std::cout << "Your Penguin number " << sickP + 1 << " got sick and died. So sorry" << std::endl; + + for (int j = sickP; j < roomOfPe; j++) { + + + Penguin temp = arra[j]; + arra[j] = arra[j + 1]; + arra[j + 1] = temp; + } + arra[roomOfPe - 1] = Penguin(0, 0.00, 0, 0.00, 0.00); + + //Check turtle! + std::cout<<"The Turtle is (after the penguin die): "<= numOfTi+numOfPe && whoSick < numOfAni + { + tu -= 1; + + int sickTu = whoSick - (ti + pe); + std::cout << "Your Turtle number " << sickTu + 1 << " got sick and died. So sorry" << std::endl; + + + for (int j = sickTu; j < roomOfTu; j++) { + + Turtle temp = array[j]; + array[j] = array[j + 1]; + array[j + 1] = temp; + } + array[roomOfTu - 1] = Turtle(0, 0.00, 0, 0.00, 0.00); + + } + + } + delete[] allAnimal; + +} + +void DArray::whoHasBaby(int &numTi, int &numPen, int &numTurt, Tiger *arr, Penguin *arra, Turtle *array){ + + Zoo zoo; + int draw; + + int numAdTi = 0; + for (int i = 0; i < numTi; i++) { + + if (arr[i].getAge() >= 3) { + numAdTi += 1; + } + } + std::cout <<"Number of Adult Tigers: " << numAdTi << std::endl; + + int *adultTiger = new int[numAdTi]; + + int j = 0; + for (int i = 0; i < numTi; i++) { + if (arr[i].getAge() >= 3) { + adultTiger[j] = i; + j++; + } + } + + int numAdPen = 0; + for (int i = 0; i < numPen; i++) { + if (arra[i].getAge() >= 3) { + numAdPen += 1; + } + } + std::cout <<"Number of Adult penguins: " << numAdPen << std::endl; + + int *adultPenguin = new int[numAdPen]; + + int k = 0; + for (int i = 0; i < numPen; i++) { + if (arra[i].getAge() >= 3) { + adultPenguin[k] = i; + k++; + } + } + + int numAdTur = 0; + for (int i = 0; i < numTurt; i++) { + if (array[i].getAge() >= 3) { + numAdTur += 1; + } + + } + std::cout << "Number of Adult Turtle: " << numAdTur << std::endl; + + int *adultTurtle = new int[numAdTur]; + + int l = 0; + for (int i = 0; i < numTurt; i++) { + if (array[i].getAge() >= 3) { + adultTurtle[l] = i; + l++; + } + } + + int numAdAnimal = numAdTi + numAdPen + numAdTur; + + std::random_device ran1; + std::mt19937 mt1(ran1()); + std::uniform_int_distribution dist(1, numAdAnimal); + draw = dist(mt1)-1; + + + if (numAdAnimal <= 0) { + std::cout << "Sorry. You don't have any adult animals. Maybe next time!" << std::endl; + + } + + else { + //A Tiger has a baby. + if (draw < numAdTi) { + + int chosenTi; + chosenTi = adultTiger[draw]; + std::cout << "Your tiger number: "<= roomOfTi) { + + this->DArray::arrayTiger(arr, roomOfTi); + + std::cout<<"Room For Tiger after resizing "<< roomOfTi<= numAdTi && draw < numAdTi + numAdPen) { + + int chosenPen; + chosenPen = adultPenguin[draw - numAdTi]; + std::cout << "Your penguin number "<= roomOfPe) { + + arrayPen(arra, roomOfPe); + std::cout<<"Room For penguin after resizing "<= numOfTi+numOfPe && whoSick < numOfAni + { + + int chosenTurtle; + chosenTurtle = adultTurtle[draw - numAdTi - numAdPen]; + std::cout << "Your Turtle number "<= roomOfTu) { + + arrayTur(array, roomOfTu); + std::cout<<"Room For Turtle after resizing "< +#include +#include +#include +#include + +Zoo::Zoo()=default; +Zoo::~Zoo()=default; + +/********************************** +int Zoo::getDay(){ + return this -> day; +} +void Zoo::setDay(int d){ + day = d; +} +int Zoo::getNumOfTig(){ + return numOfTig; +} +void Zoo::setNumOfTig(int tig){ + numOfTig =tig; + +} +int Zoo::getNumOfPeng(){ + return numOfPeng; + +} +void Zoo::setNumOfPeng(int pen){ + numOfPeng = pen; + +} +int Zoo::getNumOfTurt(){ + return numOfTurt; + +} +void Zoo::setNumOfTurt(int turt){ + numOfTurt =turt; +} +************************************************/ +void Zoo::play(){ + + std::cout<<"Welcome to the Zoo! Now you run this Fantastic Zoo."<> fBuyTi; + numOfTig = inputVal(fBuyTi); + + if(!(numOfTig==1 || numOfTig ==2)) { + + do{ + std::cin.clear(); + std::cin.ignore(INT_MAX, '\n'); + std::cout<<"Wrong input. You can buy only 1 or 2 Tigers, Please try again: "; + std::cin >> fBuyTi; + numOfTig = inputVal(fBuyTi); + }while(!(numOfTig ==1 || numOfTig==2)); + } + + for(int i =0; i > fBuyP; + numOfPeng = inputVal(fBuyP); + + if(!(numOfPeng ==1 || numOfPeng ==2)) { + + do{ + std::cin.clear(); + std::cin.ignore(INT_MAX, '\n'); + std::cout<<"Wrong input. You can buy only 1 or 2 Penguins, Please try again: "; + std::cin >> fBuyP; + numOfPeng = inputVal(fBuyP); + }while(!(numOfPeng ==1 || numOfPeng ==2)); + } + + for(int i =0; i >fBuyTu; + numOfTurt = inputVal(fBuyTu); + + if(!(numOfTurt ==1 || numOfTurt ==2)) { + + do{ + std::cin.clear(); + std::cin.ignore(INT_MAX, '\n'); + std::cout<<"Wrong input. You can buy only 1 or 2 Turtles, Please try again: "; + std::cin>>fBuyTu; + numOfTurt = inputVal(fBuyTu); + + }while(!(numOfTurt ==1 || numOfTurt ==2)); + } + + for(int i =0; i >option; + feedOpt = inputVal(option); + + if(!(feedOpt ==1 || feedOpt ==2 || feedOpt ==3)) { + + do{ + std::cin.clear(); + std::cin.ignore(INT_MAX, '\n'); + std::cout<<"Wrong input. You should input 1,2,or 3. Please try again: "; + std::cin>>option; + feedOpt = inputVal(option); + + }while(!(feedOpt ==1 || feedOpt ==2 || feedOpt ==3)); + } + + //Feed the animals and deduct the cost from the account. + costPerDay = (numOfTig*baseCost*5)+(numOfPeng*baseCost)+(numOfTurt*baseCost*0.5); + + //Random Event! + int event; + double bonus =0.00; + + std::random_device ran; + std::mt19937 mt(ran()); + + if (feedOpt == 1) { + + std::cout<<"\nYou chose cheap feeding option!"< dist7(0, 5); + cheapOpt = dist7(mt); + + event = dice[cheapOpt]; + } + + else if (feedOpt == 3) { + + std::cout<<"\nYou chose premium feeding option!"< dist8(0, 5); + premOpt = dist8(mt); + + event = dice2[premOpt]; + } + + else{ // feedOpt == 2 + + std::cout<<"\nYou chose generic feeding option!"< dist(1, 3); + event = dist(mt); + + } + + std::cout< dist3(250, 500); + bonus= dist3(mt); + std::cout<<"Your today bonus is "<>buyNewOne; + buyNew =inputVal(buyNewOne); + + if(!(buyNew ==1 || buyNew ==2)) { + + do{ + std::cin.clear(); + std::cin.ignore(INT_MAX, '\n'); + std::cout<<"Wrong input. You can only input 1 or 2, Please try again: "; + std::cin>>buyNewOne; + buyNew =inputVal(buyNewOne); + }while(!(buyNew ==1 || buyNew ==2)); + } + + if(buyNew==1) { + + double buyChoice; + int buyOneMore; + std::cout + << "\nSo, you want to buy. Good! which animal will you buy; input 1 for Tiger, 2 for Penguin, and 3 for Turtle: "; + std::cin >> buyChoice; + buyOneMore = inputVal(buyChoice); + + if(!(buyOneMore ==1 || buyOneMore ==2 || buyOneMore ==3)) { + + do{ + std::cin.clear(); + std::cin.ignore(INT_MAX, '\n'); + std::cout<<"Wrong input. You should input 1,2,or 3. Please try again: "; + std::cin >> buyChoice; + buyOneMore = inputVal(buyChoice); + + }while(!(buyOneMore ==1 || buyOneMore ==2 || buyOneMore ==3)); + } + + if (buyOneMore == 1) { + + std::cout << "So, you decided to buy a Tiger. Best Choice!" << std::endl; + if(numOfTig >= room.getRoomOfTi()) { + + room.arrayTiger(arrayOfTi, room.getRoomOfTi()); + + } + //Adds a new tiger to the array. + arrayOfTi[numOfTig] = Tiger(3, tiger.getCost(), 0, tiger.getBaseFoodCost(), tiger.getPayoff()); + numOfTig +=1; + account -= tiger.getCost(); + std::cout<<"After you buy the tiger, your balance is "<= room.getRoomOfPe()) { + + room.arrayPen(arrayOfPe, room.getRoomOfPe()); + + } + arrayOfPe[numOfPeng] = Penguin(3, penguin.getCost(), 0, penguin.getBaseFoodCost(), penguin.getPayoff()); + numOfPeng+=1; + account -= penguin.getCost(); + std::cout<<"After you buy the penguin, your balance is "<= room.getRoomOfTu()) { + + room.arrayTur(arrayOfTur, room.getRoomOfTu()); + + } + arrayOfTur[numOfTurt] = Turtle(3, turtle.getCost(), 0, turtle.getBaseFoodCost(), turtle.getPayoff()); + numOfTurt+=1; + account -= turtle.getCost(); + std::cout<<"After you buy the turtle, your balance is "<>playAgain; + std::cout< 0); + + if (account < 0){ + std::cout<<"\nI'm sorry, but your account is empty. Play next time. Good buy!"<