From 7c4276754377cdf12fb7a755415f353ef23fdf9b Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 01:30:46 -0400 Subject: [PATCH 01/18] Update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e69de29b..8ecea9b4 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,2 @@ +Name: Keith Van Dyke +FSUID: kcv15 From 45947a15800eb1ded013cb723e963caed69bf633 Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 01:44:01 -0400 Subject: [PATCH 02/18] Created doc folder and status.txt file. Updated status.txt with git status > docs/status.txt --- docs/status.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 docs/status.txt diff --git a/docs/status.txt b/docs/status.txt new file mode 100644 index 00000000..815f4f40 --- /dev/null +++ b/docs/status.txt @@ -0,0 +1,9 @@ +On branch master +Your branch is ahead of 'origin/master' by 1 commit. + (use "git push" to publish your local commits) + +Untracked files: + (use "git add ..." to include in what will be committed) + docs/ + +nothing added to commit but untracked files present (use "git add" to track) From f3e33f60fee5427a89d64b1af94912dcd058cf8d Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 01:45:43 -0400 Subject: [PATCH 03/18] Create answers.txt in docs folder --- docs/answers.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/answers.txt diff --git a/docs/answers.txt b/docs/answers.txt new file mode 100644 index 00000000..e69de29b From 18c52e1ee4418f9d3d0d40262d01cae06c679a53 Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 19:55:18 -0400 Subject: [PATCH 04/18] Create and fill out answers.txt file --- docs/answers.txt | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/docs/answers.txt b/docs/answers.txt index e69de29b..d21ca5ae 100644 --- a/docs/answers.txt +++ b/docs/answers.txt @@ -0,0 +1,65 @@ +(a) Paste the console output you saved at the end of step 3.C (2 points) + On branch master + Your branch is ahead of 'origin/master' by 1 commit. + (use "git push" to publish your local commits) + + Untracked files: + (use "git add ..." to include in what will be committed) + docs/ + + nothing added to commit but untracked files present (use "git add" to track) + +(b) How many commits have been done to the repository (not only by you, but by +anyone) so far? Write the git command you used to get this information (4 points) + 9 + git rev-list --all --count + +(c) When was the .gitignore file modified last? Write the git command you used to get +this information (4 points) + Author: Esteban Parra + Date: Wed Sep 25 18:13:30 2019 -0400 + + -> Tracking .gitignore + + git log -1 ./.gitignore + +(d) Mention two reasons why branches are used in a Git repository (4 points) + -Branches are used to separate work to specific features in a project + -Allow quick switching between contexts quickly + +(e) What is the difference between git log and git status? (4 points) + git log shows the committed project history + + git status displays the state of the working directory + and how the repository is currently structured + +(f) What command would you use to see the commits where “Vehicle.h” was one of the +committed files? (4 points) + git log Vehicle.h + +(g) What command would you use to see the commits whose commit message contains the +word “file”? (4 points) + git log --grep file + +(h) In the context of object-oriented programming (I) What is inheritance? (II) What is +polymorphism? (III) What is encapsulation? (6 points) + (I) Inheritance is the relationship objects have with each other where attributes + and behaviors can be shared in a parent-child way. + (II) I think of polymorphism as many representations. This means that an object can be + correctly represented by other objects. + (III) Encapsulation is hiding the details of an object. This is useful to the user + of a class because they are only given the information relevant to how they + can use the class. Hiding the unnecessary complexities from the user. + +(i) What is the main difference between the “Dictator and Lieutenants” workflow and the +“Integration manager” workflow? (5 points) + The first uses a dictator to push to the central repository while the second + uses an integration manager to push to the central repository. + +(j) How would a team of 100 developers benefit from following the “Dictator and +Lieutenants” workflow instead of the “Centralized” workflow? (5 points) + None of the developers have to solve any arising conflicts. This task is + performed by the lieutenants for a group of developers, and then the dictator + resolves conflicts that arise from the lieutenants' merges. This results in + the benefit of more time developing for the developers and less time solving + conflicts. From 0b951db833894fcc33dcb6caf29702db7e5ef51f Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 20:46:05 -0400 Subject: [PATCH 05/18] Implemented the Jet class --- Jet.cpp | 37 +++++++++++++++++++++++++++++++++++++ Jet.h | 27 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 Jet.cpp create mode 100644 Jet.h diff --git a/Jet.cpp b/Jet.cpp new file mode 100644 index 00000000..a285bb6f --- /dev/null +++ b/Jet.cpp @@ -0,0 +1,37 @@ +// +// Created by Keith Van Dyke on 10/04/19 +// + +#include +#include "Jet.h" + +Jet::Jet(string brand, string model, int numEngines, string fuelType) { + setBrand(brand); + setModel(model); + setEngineCount(numEngines); + setFuelType(fuelType); +} + +Jet::~Jet() = default; + +int Jet::getEngineCount() { + return numberOfEngines; +} + +void Jet::setEngineCount(int numEngines) { + numberOfEngines = numEngines; +} + +double Jet::mileageEstimate(double time) { + int rand(); + double mileage = ((rand() % 60) + 40) * time; + if (fuelType == "Rocket" && numEngines > 2) { + mileage += (mileage * 0.055) * numEngines; + } + return mileage; +} + +string Jet::toString() { + return "-> Jet\n" + PoweredVehicle::toString() + "\n\tEngines: " + + to_string(numberOfEngines); +} diff --git a/Jet.h b/Jet.h new file mode 100644 index 00000000..df59d09b --- /dev/null +++ b/Jet.h @@ -0,0 +1,27 @@ +// +// Created by Keith Van Dyke on 10/04/19 +// + +#ifndef DRIVINGSIMULATOR_JET_H +#define DRIVINGSIMULATOR_JET_H + +#include "Vehicle.h" + +class Jet : public PoweredVehicle { + +private: + int numberOfEngines; + +public: + explicit Jet(string brand, string model, string fuelType, + int numEngines = 1); + + virtual ~Jet(); + int getEngineCount(); + void setEngineCount(int numEngines); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_JET_H From 50bab8e7f820b9425bb30d53a723ce2081e3837c Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 21:10:48 -0400 Subject: [PATCH 06/18] -Created the skateboard class -Added comments to Jet.cpp -Changed random number generation to add 41 from 40 -Included PoweredVehicle.h instead of Vehicle.h in Jet.h --- Jet.cpp | 6 +++--- Jet.h | 2 +- Skateboard.cpp | 26 ++++++++++++++++++++++++++ Skateboard.h | 21 +++++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 Skateboard.cpp create mode 100644 Skateboard.h diff --git a/Jet.cpp b/Jet.cpp index a285bb6f..889eaf74 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -2,7 +2,7 @@ // Created by Keith Van Dyke on 10/04/19 // -#include +#include //for random number generation #include "Jet.h" Jet::Jet(string brand, string model, int numEngines, string fuelType) { @@ -24,9 +24,9 @@ void Jet::setEngineCount(int numEngines) { double Jet::mileageEstimate(double time) { int rand(); - double mileage = ((rand() % 60) + 40) * time; + double mileage = ((rand() % 60) + 41) * time; //generate 40-100 if (fuelType == "Rocket" && numEngines > 2) { - mileage += (mileage * 0.055) * numEngines; + mileage += (mileage * 0.055) * numEngines; //increase 5.5% of mileage for each engine } return mileage; } diff --git a/Jet.h b/Jet.h index df59d09b..c6b19bb4 100644 --- a/Jet.h +++ b/Jet.h @@ -5,7 +5,7 @@ #ifndef DRIVINGSIMULATOR_JET_H #define DRIVINGSIMULATOR_JET_H -#include "Vehicle.h" +#include "PoweredVehicle.h" class Jet : public PoweredVehicle { diff --git a/Skateboard.cpp b/Skateboard.cpp new file mode 100644 index 00000000..55293bf8 --- /dev/null +++ b/Skateboard.cpp @@ -0,0 +1,26 @@ +// +// Created by Keith Van Dyke on 10/04/19 +// + +#include +#include "Skateboard.h" + + +Skateboard::Skateboard(string brand, string model) { + setBrand(brand); + setModel(model); +} + +Skateboard::~Skateboard() = default; + +double Skateboard::mileageEstimate(double time) { + double mileage = (rand() % .5) + .1; + if(time > 25 && time < 250) { + mileage += (rand() % (time / 3)) + 1; + } + return mileage; +} + +string Skateboard::toString() { + return "-> Skateboard\n" + Vehicle::toString(); +} diff --git a/Skateboard.h b/Skateboard.h new file mode 100644 index 00000000..ce4bb03b --- /dev/null +++ b/Skateboard.h @@ -0,0 +1,21 @@ +// +// Created by Keith Van Dyke on 10/04/19 +// + +#ifndef DRIVINGSIMULATOR_SKATEBOARD_H +#define DRIVINGSIMULATOR_SKATEBOARD_H + +#include "Vehicle.h" + +class Skateboard : public Vehicle { + +public: + explicit Skateboard(string brand, string model); + + virtual ~Skateboard(); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_SKATEBOARD_H From 54bed2fcc84d6a84bafe40463057114077f8a8ad Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 21:39:55 -0400 Subject: [PATCH 07/18] -Created Sleigh class with comments --- Sleigh.cpp | 39 +++++++++++++++++++++++++++++++++++++++ Sleigh.h | 26 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 Sleigh.cpp create mode 100644 Sleigh.h diff --git a/Sleigh.cpp b/Sleigh.cpp new file mode 100644 index 00000000..9608ccd1 --- /dev/null +++ b/Sleigh.cpp @@ -0,0 +1,39 @@ +// +// Created by Keith Van Dyke on 10/04/19 +// + +#include //for random number generation +#include "Sleigh.h" + +Sleigh::Sleigh(string brand, string model, int numReindeer, string fuelType) { + setBrand(brand); + setModel(model); + setReindeerCount(numReindeer); + setFuelType(fuelType); +} + +Sleigh::~Sleigh() = default; + +int Sleigh::getReindeerCount() { + return numberOfReindeer; +} + +void Sleigh::setReindeerCount(int numReindeer) { + numberOfReindeer = numReindeer; +} + +double Sleigh::mileageEstimate(double time) { + double mileage = 1000 * time; + if (fuelType != "carrots" && numReindeer < 8) { + mileage -= (mileage * 0.30) * (8 - numReindeer); //30% decrease in speed per missing + } //reindeer if not eating carrots + else if (fuelType == "carrots" && numReindeer < 8) { + mileage -= (mileage * 0.15) * (8 - numReindeer); //15% decrease in speed per missing + } //reindeer if eating carrots + return mileage; +} + +string Sleigh::toString() { + return "-> Sleigh\n" + PoweredVehicle::toString() + "\n\tReindeer: " + + to_string(numberOfReindeer); +} diff --git a/Sleigh.h b/Sleigh.h new file mode 100644 index 00000000..80a62513 --- /dev/null +++ b/Sleigh.h @@ -0,0 +1,26 @@ +// +// Created by Keith Van Dyke on 10/04/19 +// + +#ifndef DRIVINGSIMULATOR_SLEIGH_H +#define DRIVINGSIMULATOR_SLEIGH_H + +#include "PoweredVehicle.h" + +class Sleigh : public PoweredVehicle { + +private: + int numberOfReindeer; + +public: + explicit Sleigh(string brand, string model, int numReindeer = 8); + + virtual ~Sleigh(); + int getReindeerCount(); + void setReindeerCount(int numReindeer); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_SLEIGH_H From d6490e6fb3b24f5f8d896d9fbf82374dc19e4c2d Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 21:52:58 -0400 Subject: [PATCH 08/18] -Added instances of vehicles to main -Swapped fuelType and numReindeer parameters and arguments to match other classes --- Sleigh.cpp | 2 +- Sleigh.h | 2 +- main.cpp | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Sleigh.cpp b/Sleigh.cpp index 9608ccd1..f310bdd3 100644 --- a/Sleigh.cpp +++ b/Sleigh.cpp @@ -5,7 +5,7 @@ #include //for random number generation #include "Sleigh.h" -Sleigh::Sleigh(string brand, string model, int numReindeer, string fuelType) { +Sleigh::Sleigh(string brand, string model, string fuelType, int numReindeer) { setBrand(brand); setModel(model); setReindeerCount(numReindeer); diff --git a/Sleigh.h b/Sleigh.h index 80a62513..fbf7e938 100644 --- a/Sleigh.h +++ b/Sleigh.h @@ -13,7 +13,7 @@ class Sleigh : public PoweredVehicle { int numberOfReindeer; public: - explicit Sleigh(string brand, string model, int numReindeer = 8); + explicit Sleigh(string brand, string model, string fuelType, int numReindeer = 8); virtual ~Sleigh(); int getReindeerCount(); diff --git a/main.cpp b/main.cpp index ba0b6928..4e0701de 100644 --- a/main.cpp +++ b/main.cpp @@ -16,6 +16,9 @@ int main() { vehiclesArray[3] = new Car("Tesla", "T2", "electricity", "large"); vehiclesArray[4] = new Bicycle("Mizuno", "Wave", 10); vehiclesArray[5] = new Car("BMW", "X5", "diesel", "grande"); + vehiclesArray[6] = new Sleigh("IKEA", "Slädtur", "chocolate", 4); + vehiclesArray[7] = new Sleigh("Apple", "iSleigh", "carrots", 6); + vehiclesArray[8] = new Sleigh("Ferrari", "F1 SLGH19", "carrots", 8); printVehiclesRoster(vehiclesArray, size); @@ -37,4 +40,4 @@ void printVehiclesRoster(Vehicle **vehicles, int size) { << vehicles[i]->mileageEstimate(simulatedDistance) << " miles in " << simulatedDistance << " seconds" << endl; } -} \ No newline at end of file +} From 56c0cf7c55e49e7b5af7d4698b7e00b1429b3478 Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 21:53:28 -0400 Subject: [PATCH 09/18] Changed size to 9 --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 4e0701de..a1b3b2fc 100644 --- a/main.cpp +++ b/main.cpp @@ -6,7 +6,7 @@ void printVehiclesRoster(Vehicle **vehicles, int size); int main() { std::cout << "Driving simulator" << std::endl; - int size = 6; + int size = 9; int capacity = 10; Vehicle **vehiclesArray = new Vehicle *[capacity]; From feb61cd2a3173b91e7673407ee89847b511b03f1 Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 21:55:54 -0400 Subject: [PATCH 10/18] -Put includes for the three new classes Jet Skateboard, and Sleigh -Removed library included for random number generation from Jet.cpp --- Sleigh.cpp | 1 - main.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Sleigh.cpp b/Sleigh.cpp index f310bdd3..5bd4116d 100644 --- a/Sleigh.cpp +++ b/Sleigh.cpp @@ -2,7 +2,6 @@ // Created by Keith Van Dyke on 10/04/19 // -#include //for random number generation #include "Sleigh.h" Sleigh::Sleigh(string brand, string model, string fuelType, int numReindeer) { diff --git a/main.cpp b/main.cpp index a1b3b2fc..e9d073c2 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,9 @@ #include #include "Car.h" #include "Bicycle.h" +#include "Jet.h" +#include "Skateboard.h" +#include "Sleigh.h" void printVehiclesRoster(Vehicle **vehicles, int size); From 8917ffc9d1a2a2902221d60b468a79e9a8fea4b5 Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 21:59:32 -0400 Subject: [PATCH 11/18] -Put includes for the three new classes Jet Skateboard, and Sleigh -Removed library included for random number generation from Sleigh.cpp --- Sleigh.cpp | 1 - main.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Sleigh.cpp b/Sleigh.cpp index f310bdd3..5bd4116d 100644 --- a/Sleigh.cpp +++ b/Sleigh.cpp @@ -2,7 +2,6 @@ // Created by Keith Van Dyke on 10/04/19 // -#include //for random number generation #include "Sleigh.h" Sleigh::Sleigh(string brand, string model, string fuelType, int numReindeer) { diff --git a/main.cpp b/main.cpp index a1b3b2fc..e9d073c2 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,9 @@ #include #include "Car.h" #include "Bicycle.h" +#include "Jet.h" +#include "Skateboard.h" +#include "Sleigh.h" void printVehiclesRoster(Vehicle **vehicles, int size); From 506feed61e06d2f10958fdc1e6108b866d4f81de Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 22:00:39 -0400 Subject: [PATCH 12/18] Trimmed floats generated by random numbers in Skateboard.cpp and Jet.cpp --- Jet.cpp | 5 +++-- Skateboard.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Jet.cpp b/Jet.cpp index 889eaf74..e927a9c5 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -2,7 +2,8 @@ // Created by Keith Van Dyke on 10/04/19 // -#include //for random number generation +#include +#include #include "Jet.h" Jet::Jet(string brand, string model, int numEngines, string fuelType) { @@ -24,7 +25,7 @@ void Jet::setEngineCount(int numEngines) { double Jet::mileageEstimate(double time) { int rand(); - double mileage = ((rand() % 60) + 41) * time; //generate 40-100 + double mileage = floor(((rand() % 60) + 41) * time); //generate 40-100 if (fuelType == "Rocket" && numEngines > 2) { mileage += (mileage * 0.055) * numEngines; //increase 5.5% of mileage for each engine } diff --git a/Skateboard.cpp b/Skateboard.cpp index 55293bf8..1db001e0 100644 --- a/Skateboard.cpp +++ b/Skateboard.cpp @@ -2,6 +2,7 @@ // Created by Keith Van Dyke on 10/04/19 // +#include #include #include "Skateboard.h" @@ -14,7 +15,7 @@ Skateboard::Skateboard(string brand, string model) { Skateboard::~Skateboard() = default; double Skateboard::mileageEstimate(double time) { - double mileage = (rand() % .5) + .1; + double mileage = floor((rand() % .5) + .1); if(time > 25 && time < 250) { mileage += (rand() % (time / 3)) + 1; } From 4fbc370928b2ec12966365e1a65ee349aa95b12d Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 22:57:23 -0400 Subject: [PATCH 13/18] -Corrected numberOfEngines variables in Jet.cpp -Added RandomFloat function to Skateboard.cpp and Skateboard.h -Corrected numberofReindeer variables in Sleigh.cpp -Added random generator seed to main.cpp --- Jet.cpp | 7 +++---- Skateboard.cpp | 11 +++++++++-- Skateboard.h | 1 + Sleigh.cpp | 8 ++++---- main.cpp | 2 ++ 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Jet.cpp b/Jet.cpp index e927a9c5..387a8532 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -6,7 +6,7 @@ #include #include "Jet.h" -Jet::Jet(string brand, string model, int numEngines, string fuelType) { +Jet::Jet(string brand, string model, string fuelType, int numEngines) { setBrand(brand); setModel(model); setEngineCount(numEngines); @@ -24,10 +24,9 @@ void Jet::setEngineCount(int numEngines) { } double Jet::mileageEstimate(double time) { - int rand(); double mileage = floor(((rand() % 60) + 41) * time); //generate 40-100 - if (fuelType == "Rocket" && numEngines > 2) { - mileage += (mileage * 0.055) * numEngines; //increase 5.5% of mileage for each engine + if (fuelType == "Rocket" && numberOfEngines > 2) { + mileage += (mileage * 0.055) * numberOfEngines; //increase 5.5% of mileage for each engine } return mileage; } diff --git a/Skateboard.cpp b/Skateboard.cpp index 1db001e0..5282a573 100644 --- a/Skateboard.cpp +++ b/Skateboard.cpp @@ -14,10 +14,17 @@ Skateboard::Skateboard(string brand, string model) { Skateboard::~Skateboard() = default; +float Skateboard::RandomFloat(float a, float b) { + float random = ((float) rand()) / (float) RAND_MAX; + float diff = b - a; + float r = random * diff; + return a + r; +} + double Skateboard::mileageEstimate(double time) { - double mileage = floor((rand() % .5) + .1); + double mileage = floor(RandomFloat(0.1, 0.5)); if(time > 25 && time < 250) { - mileage += (rand() % (time / 3)) + 1; + mileage += floor((RandomFloat(1, time / 3))); } return mileage; } diff --git a/Skateboard.h b/Skateboard.h index ce4bb03b..ed7720d0 100644 --- a/Skateboard.h +++ b/Skateboard.h @@ -13,6 +13,7 @@ class Skateboard : public Vehicle { explicit Skateboard(string brand, string model); virtual ~Skateboard(); + float RandomFloat(float a, float b); virtual double mileageEstimate(double time); virtual string toString(); }; diff --git a/Sleigh.cpp b/Sleigh.cpp index 5bd4116d..f24a1404 100644 --- a/Sleigh.cpp +++ b/Sleigh.cpp @@ -23,11 +23,11 @@ void Sleigh::setReindeerCount(int numReindeer) { double Sleigh::mileageEstimate(double time) { double mileage = 1000 * time; - if (fuelType != "carrots" && numReindeer < 8) { - mileage -= (mileage * 0.30) * (8 - numReindeer); //30% decrease in speed per missing + if (fuelType != "carrots" && numberOfReindeer < 8) { + mileage -= (mileage * 0.30) * (8 - numberOfReindeer); //30% decrease in speed per missing } //reindeer if not eating carrots - else if (fuelType == "carrots" && numReindeer < 8) { - mileage -= (mileage * 0.15) * (8 - numReindeer); //15% decrease in speed per missing + else if (fuelType == "carrots" && numberOfReindeer < 8) { + mileage -= (mileage * 0.15) * (8 - numberOfReindeer); //15% decrease in speed per missing } //reindeer if eating carrots return mileage; } diff --git a/main.cpp b/main.cpp index e9d073c2..222c2d12 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,5 @@ #include +#include #include "Car.h" #include "Bicycle.h" #include "Jet.h" @@ -8,6 +9,7 @@ void printVehiclesRoster(Vehicle **vehicles, int size); int main() { + srand(time(NULL)); std::cout << "Driving simulator" << std::endl; int size = 9; int capacity = 10; From 9dab29b3f15bfca29b8cf77142839c44381f4fae Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 23:11:57 -0400 Subject: [PATCH 14/18] -Added missing Jet and Skateboard classes instances -Changed Sleigh.cpp so that if mileage is below 0, return 0. --- Sleigh.cpp | 3 +++ main.cpp | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Sleigh.cpp b/Sleigh.cpp index f24a1404..57c5a61e 100644 --- a/Sleigh.cpp +++ b/Sleigh.cpp @@ -29,6 +29,9 @@ double Sleigh::mileageEstimate(double time) { else if (fuelType == "carrots" && numberOfReindeer < 8) { mileage -= (mileage * 0.15) * (8 - numberOfReindeer); //15% decrease in speed per missing } //reindeer if eating carrots + if (mileage < 0) { + return 0; + } return mileage; } diff --git a/main.cpp b/main.cpp index 222c2d12..ba7828b9 100644 --- a/main.cpp +++ b/main.cpp @@ -11,8 +11,8 @@ void printVehiclesRoster(Vehicle **vehicles, int size); int main() { srand(time(NULL)); std::cout << "Driving simulator" << std::endl; - int size = 9; - int capacity = 10; + int size = 12; + int capacity = 12; Vehicle **vehiclesArray = new Vehicle *[capacity]; vehiclesArray[0] = new Car(); @@ -21,9 +21,12 @@ int main() { vehiclesArray[3] = new Car("Tesla", "T2", "electricity", "large"); vehiclesArray[4] = new Bicycle("Mizuno", "Wave", 10); vehiclesArray[5] = new Car("BMW", "X5", "diesel", "grande"); - vehiclesArray[6] = new Sleigh("IKEA", "Slädtur", "chocolate", 4); - vehiclesArray[7] = new Sleigh("Apple", "iSleigh", "carrots", 6); - vehiclesArray[8] = new Sleigh("Ferrari", "F1 SLGH19", "carrots", 8); + vehiclesArray[6] = new Jet("Cessna", "CJ4", "Avgas", 2); + vehiclesArray[7] = new Jet("Cessna", "CJ5", "Rocket", 4); + vehiclesArray[8] = new Skateboard("Enjoi", "Whitey Panda"); + vehiclesArray[9] = new Sleigh("IKEA", "Slädtur", "chocolate", 4); + vehiclesArray[10] = new Sleigh("Apple", "iSleigh", "carrots", 6); + vehiclesArray[11] = new Sleigh("Ferrari", "F1 SLGH19", "carrots", 8); printVehiclesRoster(vehiclesArray, size); From 6aeeb2e6f194b975a60a39ae817d87fa546ec5b5 Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 23:18:24 -0400 Subject: [PATCH 15/18] -Changed Sleigh --- Sleigh.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sleigh.cpp b/Sleigh.cpp index 57c5a61e..f24a1404 100644 --- a/Sleigh.cpp +++ b/Sleigh.cpp @@ -29,9 +29,6 @@ double Sleigh::mileageEstimate(double time) { else if (fuelType == "carrots" && numberOfReindeer < 8) { mileage -= (mileage * 0.15) * (8 - numberOfReindeer); //15% decrease in speed per missing } //reindeer if eating carrots - if (mileage < 0) { - return 0; - } return mileage; } From e1cf0bb37e547f95ff755ba6a66fe3268b104226 Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 23:23:08 -0400 Subject: [PATCH 16/18] -Re-add Sleigh.cpp return 0 for mileage if less than zero. Local and remote somehow got out of sync, so I had to "git checkout HEAD^ sleigh.cpp", pull, then update Sleigh.cpp again --- Sleigh.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sleigh.cpp b/Sleigh.cpp index f24a1404..57c5a61e 100644 --- a/Sleigh.cpp +++ b/Sleigh.cpp @@ -29,6 +29,9 @@ double Sleigh::mileageEstimate(double time) { else if (fuelType == "carrots" && numberOfReindeer < 8) { mileage -= (mileage * 0.15) * (8 - numberOfReindeer); //15% decrease in speed per missing } //reindeer if eating carrots + if (mileage < 0) { + return 0; + } return mileage; } From f9d1756a58f01151582e222b3d26e78ebdc565e4 Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 23:32:46 -0400 Subject: [PATCH 17/18] Answered (5) in answers.txt --- docs/answers.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/answers.txt b/docs/answers.txt index d21ca5ae..d0d1250f 100644 --- a/docs/answers.txt +++ b/docs/answers.txt @@ -29,8 +29,8 @@ this information (4 points) (e) What is the difference between git log and git status? (4 points) git log shows the committed project history - - git status displays the state of the working directory + + git status displays the state of the working directory and how the repository is currently structured (f) What command would you use to see the commits where “Vehicle.h” was one of the @@ -61,5 +61,13 @@ Lieutenants” workflow instead of the “Centralized” workflow? (5 points) None of the developers have to solve any arising conflicts. This task is performed by the lieutenants for a group of developers, and then the dictator resolves conflicts that arise from the lieutenants' merges. This results in - the benefit of more time developing for the developers and less time solving + the benefit of more time developing for the developers and less time solving conflicts. + +(5) Is the Driving simulator prototype using polymorphism and/or encapsulation? If you find that +the prototype is using any of these two OOP principles, please discuss in which way the +prototype is using it. + This project is using both polymorphism and encapsulation. It is using polymorphism + when we have a car, bicycle, jet, skateboard, and sleigh which are different objects + but are all also a Vehicle object. It is using encapsulation when using getter and setter + functions to hide class attributes, making manipulation of the class itself much easier. From 2e858ecd1daeb17cb7456a33d26533295309589f Mon Sep 17 00:00:00 2001 From: Camper Van Dyke Date: Fri, 4 Oct 2019 23:36:27 -0400 Subject: [PATCH 18/18] Added comments to Skateboard.cpp --- Skateboard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Skateboard.cpp b/Skateboard.cpp index 5282a573..6cc4ab3d 100644 --- a/Skateboard.cpp +++ b/Skateboard.cpp @@ -14,8 +14,8 @@ Skateboard::Skateboard(string brand, string model) { Skateboard::~Skateboard() = default; -float Skateboard::RandomFloat(float a, float b) { - float random = ((float) rand()) / (float) RAND_MAX; +float Skateboard::RandomFloat(float a, float b) { //float function from https://stackoverflow.com/questions/5289613/generate-random-float-between-two-floats/5289624 + float random = ((float) rand()) / (float) RAND_MAX; //other rand() implementations in project done without help float diff = b - a; float r = random * diff; return a + r;