From ad5ec7f8ff8ea168a382552026007fabaa00aff0 Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Tue, 1 Oct 2019 20:35:47 -0400 Subject: [PATCH 01/17] Add name and FSUID --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e69de29b..1b1246a5 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,2 @@ +Name: Noal Gesler +FSUID: ntg16 \ No newline at end of file From b1a64189c304865fbf2c02926bc9fef562f35169 Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Wed, 2 Oct 2019 21:30:37 -0400 Subject: [PATCH 02/17] Created status.txt Pasted output from command git status --- status.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 status.txt diff --git a/status.txt b/status.txt new file mode 100644 index 00000000..cce0c80f --- /dev/null +++ b/status.txt @@ -0,0 +1,19 @@ +On branch master + +No commits yet + +Untracked files: + (use "git add ..." to include in what will be committed) + .gitignore + Bicycle.cpp + Bicycle.h + Car.cpp + Car.h + PoweredVehicle.cpp + PoweredVehicle.h + README.md + Vehicle.cpp + Vehicle.h + main.cpp + +nothing added to commit but untracked files present (use "git add" to track) From 514adac4036d6f621e6065b1f66ba2ec482f07ed Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Wed, 2 Oct 2019 23:30:36 -0400 Subject: [PATCH 03/17] Created answers.txt Contains all answers for part E of assignment 2 --- answers.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 answers.txt diff --git a/answers.txt b/answers.txt new file mode 100644 index 00000000..2f44449b --- /dev/null +++ b/answers.txt @@ -0,0 +1,22 @@ +a. To https://github.com/NoalGesler/assignment2.git + +b. 2; git rev-list --count HEAD + +c. 7 days ago; git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --format="%ai {}" {} + +d. Allow for work to happen parallel to each other in different branches and for preparing/testing different versions of the porject. + +e. git log will only view committed history, while git status will allow you to inspect the full directory. + +f. git log --follow -- Vehicle.h + +g. git log --all --grep='file' + +h. + I. A child class inherits properties and variables from its parent + II. Having multiple varieties of the same class/functions from overloading + III. Bundling together data that is often used together such as a class + +i. In Dictator and Lieutenants, pushes by developers are made to lieutenant repositories, while in Integration manager, pushes by developers are made to public repositories + +j. Any changes in the project and errors in the code can be overseen by the Dictator \ No newline at end of file From ee7ccd8adc658bfb2999ad60ff1aa3775fb281d9 Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 01:43:24 -0400 Subject: [PATCH 04/17] Created Jet.h New class type Jet.h, child class which inherits functionality from PoweredVehicle class --- Jet.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Jet.h diff --git a/Jet.h b/Jet.h new file mode 100644 index 00000000..f02dda10 --- /dev/null +++ b/Jet.h @@ -0,0 +1,27 @@ +#ifndef DRIVINGSIMULATOR_JET_H +#define DRIVINGSIMULATOR_JET_H + +#include "PoweredVehicle.h" + +class Jet : public PoweredVehicle { + +private: + int numberOfEngines = 1; + string myEngineSize; + +public: + Jet(); + + explicit Jet(string brand, string model, string fuelType, + string engineSize, int numberOfEngines); + + virtual ~Jet(); + string getEngineSize(); + void setEngineSize(string engineSize); + virtual double mileageEstimate(double time); + virtual string toString(); + int setNumberOfEngines(int engineCount) +}; + + +#endif //DRIVINGSIMULATOR_JET_H From 3314140b3c3263ca72e0e8cfebdde8d8e3f7cb25 Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 01:44:12 -0400 Subject: [PATCH 05/17] Created Jet.cpp Jet.cpp defines functions of Jet.h, which inherits functionality from PoweredVehicle parent class. --- Jet.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Jet.cpp diff --git a/Jet.cpp b/Jet.cpp new file mode 100644 index 00000000..313e37c8 --- /dev/null +++ b/Jet.cpp @@ -0,0 +1,56 @@ +#include "Jet.h" +#include +#include +#include + +Jet::Jet() { + myEngineSize = "unknown"; + setBrand("unknown"); + setModel("unkown"); + setNumberOfEngines(1); +} + +Jet::Jet(string brand, string model, string fuelType, string engineSize, int numberOfEngines) { + setBrand(brand); + setModel(model); + setFuelType(fuelType); + setEngineSize(engineSize); + setNumberOfEngines(numberOfEngines); +} + +Jet::~Jet() = default; + +string Jet::getEngineSize() { + return myEngineSize; +} + +void Jet::setEngineSize(string engineSize) { + if (engineSize == "unknown" || engineSize == "small" || + engineSize == "medium" || engineSize == "grande") { + myEngineSize = engineSize; + } + else { + myEngineSize = "unknown"; + } + +} + +double Jet::mileageEstimate(double time) { + srand((unsigned)time(0)); + int mileage; + mileage = (rand() % 60) + 41; + if (fuelType == "Rocket" && numberOfEngines >= 2) { + double i = (numberOfEngines * 0.055) + 1; + mileage = mileage * i; + } + return mileage; +} + +string Jet::toString() { + return "-> Jet\n" + PoweredVehicle::toString() + "\n\tEngine Size: " + + getEngineSize(); +} + +void Jet::setNumberOfEngines(int engineCount){ + numberOfEngines = engineCount; +} \ No newline at end of file From abe55846e47010b09282281184217dee8739fb42 Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 15:40:32 -0400 Subject: [PATCH 06/17] Updated Jet.h Removed unnecessary functions and variables --- Jet.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Jet.h b/Jet.h index f02dda10..07a6e285 100644 --- a/Jet.h +++ b/Jet.h @@ -7,17 +7,14 @@ class Jet : public PoweredVehicle { private: int numberOfEngines = 1; - string myEngineSize; public: Jet(); explicit Jet(string brand, string model, string fuelType, - string engineSize, int numberOfEngines); + int numberOfEngines); virtual ~Jet(); - string getEngineSize(); - void setEngineSize(string engineSize); virtual double mileageEstimate(double time); virtual string toString(); int setNumberOfEngines(int engineCount) From 5c4d20d1e79e6e3e1cb3250d4d09ce12f71f0912 Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 15:41:03 -0400 Subject: [PATCH 07/17] Updated Jet.cpp Removed unnecessary functions and their implementation. --- Jet.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Jet.cpp b/Jet.cpp index 313e37c8..ab8afabf 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -4,7 +4,6 @@ #include Jet::Jet() { - myEngineSize = "unknown"; setBrand("unknown"); setModel("unkown"); setNumberOfEngines(1); @@ -14,27 +13,11 @@ Jet::Jet(string brand, string model, string fuelType, string engineSize, int num setBrand(brand); setModel(model); setFuelType(fuelType); - setEngineSize(engineSize); setNumberOfEngines(numberOfEngines); } Jet::~Jet() = default; -string Jet::getEngineSize() { - return myEngineSize; -} - -void Jet::setEngineSize(string engineSize) { - if (engineSize == "unknown" || engineSize == "small" || - engineSize == "medium" || engineSize == "grande") { - myEngineSize = engineSize; - } - else { - myEngineSize = "unknown"; - } - -} - double Jet::mileageEstimate(double time) { srand((unsigned)time(0)); int mileage; From 3bc5420276738a691aa97508a9e2b03aa2f3b5fa Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 16:00:49 -0400 Subject: [PATCH 08/17] Updated Jet.cpp Edited toString function --- Jet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jet.cpp b/Jet.cpp index ab8afabf..21e84081 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -30,8 +30,7 @@ double Jet::mileageEstimate(double time) { } string Jet::toString() { - return "-> Jet\n" + PoweredVehicle::toString() + "\n\tEngine Size: " + - getEngineSize(); + return "-> Jet\n" + PoweredVehicle::toString(); } void Jet::setNumberOfEngines(int engineCount){ From dec1a4d7acc0af4d3da4722f4264dfbf36e65541 Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 16:01:11 -0400 Subject: [PATCH 09/17] Updated Jet.h Changed toString function From 68455f2adaf21a05be6de556871e852e7da11bcf Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 16:19:53 -0400 Subject: [PATCH 10/17] Edited Jet.cpp Changed implementation of mileage prediction --- Jet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jet.cpp b/Jet.cpp index 21e84081..8a30e565 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -24,7 +24,7 @@ double Jet::mileageEstimate(double time) { mileage = (rand() % 60) + 41; if (fuelType == "Rocket" && numberOfEngines >= 2) { double i = (numberOfEngines * 0.055) + 1; - mileage = mileage * i; + mileage = mileage * i * time; } return mileage; } From e65cb4c16055ee71fa5d3f36f9b3f2e96d7f86c7 Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 16:51:44 -0400 Subject: [PATCH 11/17] Created Skateboard.h Declaration of all variables and functions of Skateboard class --- Skateboard.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Skateboard.h diff --git a/Skateboard.h b/Skateboard.h new file mode 100644 index 00000000..19e6d7f3 --- /dev/null +++ b/Skateboard.h @@ -0,0 +1,17 @@ +#ifndef DRIVINGSIMULATOR_SKATEBOARD_H +#define DRIVINGSIMULATOR_SKATEBOARD_H + +#include "Skateboard.h" + +class Skateboard : public Vehicle { + +public: + explicit Skateboard(string brand, string model); + + virtual ~Skateboard(); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_BICYCLE_H From 6254e21d93dbb3efc2115adc2fd3eaeb1eaa072f Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 16:52:42 -0400 Subject: [PATCH 12/17] Created Skateboard.cpp Implementation of all functions associated with Skateboard class, inherits from parent class Vehicle --- Skateboard.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Skateboard.cpp diff --git a/Skateboard.cpp b/Skateboard.cpp new file mode 100644 index 00000000..c3e5f02c --- /dev/null +++ b/Skateboard.cpp @@ -0,0 +1,28 @@ +#include "Skateboard.h" +#include +#include +#include + +Skateboard::Skateboard(string brand, string model) { + setBrand(brand); + setModel(model); +} + +Skateboard::~Skateboard() = default; + +double Skateboard::mileageEstimate(double time) { + srand((unsigned)time(0)); + double i = (rand() % 0.4) + 0.1; + int mileage = i * time; + if (time > 25 && time < 250) { + int j = (time / 3) - 1; + int h = (rand() % j) + 1; + mileage = mileage + h; + } + return mileage; +} + +string Bicycle::toString() { + string s = "-> Bicycle\n\t"; + return "-> Bicycle\n" + Vehicle::toString(); +} \ No newline at end of file From c596bcceee59e8bff7ce4c3656ad83f10edd0eca Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 18:57:29 -0400 Subject: [PATCH 13/17] Created Scooter.h Created new class Scooter and declared functions, inherited from parent class Vehicle --- Scooter.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Scooter.h diff --git a/Scooter.h b/Scooter.h new file mode 100644 index 00000000..447a9227 --- /dev/null +++ b/Scooter.h @@ -0,0 +1,18 @@ +#ifndef DRIVINGSIMULATOR_SCOOTER_H +#define DRIVINGSIMULATOR_SCOOTER_H + +#include "Vehicle.h" + +class Scooter : public Vehicle { + +public: + explicit Scooter(string brand, string model); + + virtual ~Scooter(); + virtual double mileageEstimate(double time); + + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_SCOOTER_H \ No newline at end of file From 4307917fdb0d20b8a8d582b7eaad485a1ef3a37e Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Thu, 3 Oct 2019 18:58:15 -0400 Subject: [PATCH 14/17] Created Scooter.cpp Implementation of functions in new Scooter class, inherited from parent class Vehicle. --- Scooter.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Scooter.cpp diff --git a/Scooter.cpp b/Scooter.cpp new file mode 100644 index 00000000..03ee9ffc --- /dev/null +++ b/Scooter.cpp @@ -0,0 +1,23 @@ +#include "Scooter.h" + + +Scooter::Scooter(string brand, string model) { + setBrand(brand); + setModel(model); +} + +Scooter::~Scooter() = default; + +double Scooter::mileageEstimate(double time) { + int milage = 3 * time; + double i = time * 0.05; + if (time > 30) { + mileage = mileage - i; + } + return mileage; +} + +string Scooter::toString() { + string s = "-> Scooter\n\t"; + return "-> Scooter\n" + Vehicle::toString(); +} \ No newline at end of file From dbea6f02e942b10ef3b9248f0e31d0cfc4c9c0f1 Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Fri, 4 Oct 2019 00:42:11 -0400 Subject: [PATCH 15/17] Edited Jet.cpp Removed an unnecessary variable in Jet class --- Jet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jet.cpp b/Jet.cpp index 8a30e565..8a80f20e 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -9,11 +9,10 @@ Jet::Jet() { setNumberOfEngines(1); } -Jet::Jet(string brand, string model, string fuelType, string engineSize, int numberOfEngines) { +Jet::Jet(string brand, string model, string fuelType, int numberOfEngines) { setBrand(brand); setModel(model); setFuelType(fuelType); - setNumberOfEngines(numberOfEngines); } Jet::~Jet() = default; From 536d55190e83da000c68ba871fa51bb0bcfe1adb Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Fri, 4 Oct 2019 00:51:22 -0400 Subject: [PATCH 16/17] Edited main.cpp Added test cases for 3 new classes Jet, Skateboard, and Scooter --- main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.cpp b/main.cpp index ba0b6928..eb2662aa 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,11 @@ #include #include "Car.h" #include "Bicycle.h" +#include "Jet.h" +#include "Skateboard.h" +#include "Scooter.h" +#include +#include void printVehiclesRoster(Vehicle **vehicles, int size); @@ -16,6 +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 Jet("Brand", "Model", "Rocket", "2"); + vehiclesArray[7] = new Jet("Brand", "Model", "diesel", "1"); + vehiclesArray[8] = new Skateboard("Brand", "Model"); + vehiclesArray[9] = new Skateboard("Tony", "Hawk"); + vehiclesArray[10] = new Scooter("Brand", "Model"); + vehiclesArray[11] = new Scooter("Razor", "Blue"); printVehiclesRoster(vehiclesArray, size); From 8d5e99d41705fe3656f2edbc14315814b401548c Mon Sep 17 00:00:00 2001 From: NoalGesler <55504625+NoalGesler@users.noreply.github.com> Date: Fri, 4 Oct 2019 00:54:47 -0400 Subject: [PATCH 17/17] Updated answers.txt Included answer for part 5 of assignment. --- answers.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/answers.txt b/answers.txt index 2f44449b..a63ba1d2 100644 --- a/answers.txt +++ b/answers.txt @@ -19,4 +19,6 @@ h. i. In Dictator and Lieutenants, pushes by developers are made to lieutenant repositories, while in Integration manager, pushes by developers are made to public repositories -j. Any changes in the project and errors in the code can be overseen by the Dictator \ No newline at end of file +j. Any changes in the project and errors in the code can be overseen by the Dictator + +5. The Driving simulator prototype is using both polymorphism and encapsulation. It is using polymorphism in that it contains multiple variations of Constructors, such as a default constructor and an explicit constructor. It is using encapsulation in that all classes are child classes of either Vehicle or PoweredVehicle, and PoweredVehicle is a child class of Vehicle.