From 889d9ef9512dd88903d41d97c03b6f3503bb3541 Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Wed, 2 Oct 2019 13:12:23 -0400 Subject: [PATCH 01/13] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e69de29b..c842b13c 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,2 @@ +Name: Conner Flynn +FSUID: cjf16e From 1ac4a3fd66bbea6082cc034289035054ddabc749 Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Wed, 2 Oct 2019 13:17:51 -0400 Subject: [PATCH 02/13] Revert "Update README.md" This reverts commit 889d9ef9512dd88903d41d97c03b6f3503bb3541. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index c842b13c..e69de29b 100644 --- a/README.md +++ b/README.md @@ -1,2 +0,0 @@ -Name: Conner Flynn -FSUID: cjf16e From 4204fcf5b1fa42c206715188fb56eac17ead590e Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Wed, 2 Oct 2019 13:20:26 -0400 Subject: [PATCH 03/13] Update README.md Student information added to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e69de29b..c842b13c 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,2 @@ +Name: Conner Flynn +FSUID: cjf16e From 2602b14d1e2753d3b3bec54b10550b90d284417a Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Wed, 2 Oct 2019 22:14:28 -0400 Subject: [PATCH 04/13] Create Jet and Skateboard classes --- Jet.cpp | 1 + Jet.h | 1 + Skateboard.cpp | 1 + Skateboard.h | 1 + 4 files changed, 4 insertions(+) create mode 100644 Jet.cpp create mode 100644 Jet.h create mode 100644 Skateboard.cpp create mode 100644 Skateboard.h diff --git a/Jet.cpp b/Jet.cpp new file mode 100644 index 00000000..5d3d9fdf --- /dev/null +++ b/Jet.cpp @@ -0,0 +1 @@ +//Jet.cpp diff --git a/Jet.h b/Jet.h new file mode 100644 index 00000000..357f8ec7 --- /dev/null +++ b/Jet.h @@ -0,0 +1 @@ +//Jet.h diff --git a/Skateboard.cpp b/Skateboard.cpp new file mode 100644 index 00000000..0b7973ec --- /dev/null +++ b/Skateboard.cpp @@ -0,0 +1 @@ +//Skateboard.cpp diff --git a/Skateboard.h b/Skateboard.h new file mode 100644 index 00000000..54986293 --- /dev/null +++ b/Skateboard.h @@ -0,0 +1 @@ +//Skateboard.h From 1be310110c5192e53995fd25d6dfa10565e47299 Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Wed, 2 Oct 2019 22:50:08 -0400 Subject: [PATCH 05/13] Set up Jet header and Jet cpp --- Jet.cpp | 21 +++++++++++++++++++++ Jet.h | 28 +++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Jet.cpp b/Jet.cpp index 5d3d9fdf..69430731 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -1 +1,22 @@ //Jet.cpp + +#include "Jet.h" + +Jet::Jet() { + setFuelType("unknown"); +} + +Jet::~Jet() = default; + +string Jet::getFuelType() { + return fuelType; +} + +void Jet::setFuelType(string fuel) { + fuelType = fuel; +} + +string Jet::toString() { + return Vehicle::toString() + "\n\tFuelType: " + getFuelType(); +} + diff --git a/Jet.h b/Jet.h index 357f8ec7..bac358b0 100644 --- a/Jet.h +++ b/Jet.h @@ -1 +1,27 @@ -//Jet.h +// +// Conner Flynn (cjf16e) 10/2/19 +// + +#ifndef DRIVINGSIMULATOR_JET_H +#define DRIVINGSIMULATOR_JET_H + +#include "PoweredVehicle.h" + +class Jet : public PoweredVehicle { + +private: + int numberOfEngines; + +public: + Jet(); + + explicit Jet(string brand, string model, string fuelType, int numberOfEngines = 1); + + virtual ~Jet(); + string getFuelType(); + virtual string toString(); + virtual double mileageEstimate(double time); +}; + + +#endif //DRIVINGSIMULATOR_JET_H \ No newline at end of file From ac23fe5a381f11bb697543bdef00d225acb0f79b Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Wed, 2 Oct 2019 23:36:24 -0400 Subject: [PATCH 06/13] Implementing Jet definitions and functions --- Jet.cpp | 26 +++++++++++++++++++++++++- Jet.h | 7 ++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Jet.cpp b/Jet.cpp index 69430731..f6e2be29 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -4,14 +4,38 @@ Jet::Jet() { setFuelType("unknown"); + setBrand("custom"); //XOJET + setModel("custom"); //Bombardier +} + +Jet::Jet(string brand, string model, string fuelType, int numberOfEngines){ + setBrand(brand); + setModel(model); + setFuelType(fuelType); + setEngineSize(engineSize); } Jet::~Jet() = default; -string Jet::getFuelType() { +string Jet::setFuelType() { return fuelType; } +int Jet::getNumberOfEngines() { + return numberOfEngines; +} + +void Car::setNumberOfEngines(int numberOfEngines) { + if (engineSize == "unknown" || engineSize == "small" || + engineSize == "medium" || engineSize == "grande") { + myEngineSize = engineSize; + } else { + myEngineSize = "unknown"; + } + +} + + void Jet::setFuelType(string fuel) { fuelType = fuel; } diff --git a/Jet.h b/Jet.h index bac358b0..f28cc984 100644 --- a/Jet.h +++ b/Jet.h @@ -18,9 +18,10 @@ class Jet : public PoweredVehicle { explicit Jet(string brand, string model, string fuelType, int numberOfEngines = 1); virtual ~Jet(); - string getFuelType(); - virtual string toString(); - virtual double mileageEstimate(double time); + int getNumberOfEngines(); + void setNumberOfEngines(int numberOfEngines); + virtual double mileageEstimate(double time); + virtual string toString(); }; From 347fce8c30b5cc1d57dc60e8eb3a9becebd1efea Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Thu, 3 Oct 2019 10:15:57 -0400 Subject: [PATCH 07/13] Testing new machine sync --- Skateboard.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Skateboard.cpp b/Skateboard.cpp index 0b7973ec..fc5faf9c 100644 --- a/Skateboard.cpp +++ b/Skateboard.cpp @@ -1 +1,2 @@ //Skateboard.cpp +//TEST CHANGE From ce826586d81bed15e3f9da53305398fe8203dd08 Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Fri, 4 Oct 2019 09:52:13 -0400 Subject: [PATCH 08/13] Jet header and cpp finished --- Jet.cpp | 41 ++++++++++++++++++++++++++++++----------- Jet.h | 5 +++-- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Jet.cpp b/Jet.cpp index f6e2be29..6b0ee80f 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -1,6 +1,13 @@ -//Jet.cpp +// +// Conner Flynn (cjf16e) 10/2/19 +// #include "Jet.h" +#include +#include +#include +// #include +// #include Jet::Jet() { setFuelType("unknown"); @@ -12,7 +19,7 @@ Jet::Jet(string brand, string model, string fuelType, int numberOfEngines){ setBrand(brand); setModel(model); setFuelType(fuelType); - setEngineSize(engineSize); + setNumberOfEngines(numberOfEngines); } Jet::~Jet() = default; @@ -25,22 +32,34 @@ int Jet::getNumberOfEngines() { return numberOfEngines; } -void Car::setNumberOfEngines(int numberOfEngines) { - if (engineSize == "unknown" || engineSize == "small" || - engineSize == "medium" || engineSize == "grande") { - myEngineSize = engineSize; - } else { - myEngineSize = "unknown"; - } - +void Jet::setNumberOfEngines(int engines) { + numberOfEngines = engines; } +double Jet::mileageEstimate(double time) { + // srand(time(0)); + // int max = 100; + // int min = 40; + + // double mileage = (min + (rand() % (max - min + 1 ))) * time; + + random_device rd; + mt19937 gen(rd()); + uniform_int_distribution<> dis(40, 100); + double mileage = dis(gen) * time; + + if (numberOfEngines > 2 && fuelType == "Rocket") { + mileage += mileage * 0.055; + } + return floor(mileage); +} void Jet::setFuelType(string fuel) { fuelType = fuel; } string Jet::toString() { - return Vehicle::toString() + "\n\tFuelType: " + getFuelType(); + return "-> Jet\n" + PoweredVehicle::toString() + "\n\Number of Engines: " + + getNumberOfEngines(); } diff --git a/Jet.h b/Jet.h index f28cc984..90022fc1 100644 --- a/Jet.h +++ b/Jet.h @@ -15,11 +15,12 @@ class Jet : public PoweredVehicle { public: Jet(); - explicit Jet(string brand, string model, string fuelType, int numberOfEngines = 1); + explicit Jet(string brand, string model, string fuelType, + int numberOfEngines = 1); virtual ~Jet(); int getNumberOfEngines(); - void setNumberOfEngines(int numberOfEngines); + void setNumberOfEngines(int engines); virtual double mileageEstimate(double time); virtual string toString(); }; From 06ece19b9a0dba562fdf5627f0f951f22e92c356 Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Fri, 4 Oct 2019 11:16:21 -0400 Subject: [PATCH 09/13] Skateboard setup + mileage function complete --- Skateboard.cpp | 34 ++++++++++++++++++++++++++++++++-- Skateboard.h | 24 +++++++++++++++++++++++- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/Skateboard.cpp b/Skateboard.cpp index fc5faf9c..b7ea8a1e 100644 --- a/Skateboard.cpp +++ b/Skateboard.cpp @@ -1,2 +1,32 @@ -//Skateboard.cpp -//TEST CHANGE +// +// Conner Flynn (cjf16e) 10/4/19 +// + +#include "Skateboard.h" +#include +#include + +Skateboard::Skateboard(string brand, string model) { + setBrand(brand); + setModel(model); +} + +Skateboard::~Skateboard() = default; + +double Skateboard::mileageEstimate(double time) { + random_device rd; + mt19937 gen(rd()); + uniform_real_distribution dis(0.1, 0.5); + double mileage = dis(gen) * time; + + if (time > 25 && time < 250) { + uniform_real_distribution dis(1, (time/3)); + mileage += mileage * dis(gen); + } + return floor(mileage); +} + +string Skateboard::toString() { + string s = "-> Skateboard\n\t"; + return "-> Skateboard\n" + Vehicle::toString() + "\n"; +} diff --git a/Skateboard.h b/Skateboard.h index 54986293..9dbb70eb 100644 --- a/Skateboard.h +++ b/Skateboard.h @@ -1 +1,23 @@ -//Skateboard.h +// +// Conner Flynn (cjf16e) 10/2/19 +// + +#ifndef DRIVINGSIMULATOR_SKATEBOARD_H +#define DRIVINGSIMULATOR_SKATEBOARD_H + +#include "Vehicle.h" + +class Skateboard : public Vehicle { + +private: + +public: + explicit Bicycle(string brand, string model); + + virtual ~Bicycle(); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_SKATEBOARD_H \ No newline at end of file From 9432aeacbda84d7ce37cce20edf1df7b9acfe2fd Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Fri, 4 Oct 2019 11:46:18 -0400 Subject: [PATCH 10/13] Train nontrivial mileage finished --- Train.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Train.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 Train.cpp create mode 100644 Train.h diff --git a/Train.cpp b/Train.cpp new file mode 100644 index 00000000..ff68fc88 --- /dev/null +++ b/Train.cpp @@ -0,0 +1,53 @@ +//train.cpp +// +// Conner Flynn (cjf16e) 10/2/19 + +#include "Train.h" + +Train::Train() { + myEngineSize = "none"; + setBrand("Amtrak"); + setModel("ACS-64"); +} + +Train::Train(string brand, string model, string fuelType, string engineSize) { + setBrand(brand); + setModel(model); + setFuelType(fuelType); + setEngineSize(engineSize); +} + +Train::~Train() = default; + +string Train::getEngineSize() { + return myEngineSize; +} + +void Train::setEngineSize(string engineSize) { + if (engineSize == "unknown" || engineSize == "small" || + engineSize == "medium" || engineSize == "grande") { + myEngineSize = engineSize; + } else { + myEngineSize = "unknown"; + } + +} + +double Train::mileageEstimate(double time) { + // electric locomotive top speed (w/ passengers): 200 (3.33 mi/min) + // diesel locomotive top speed (w/ passengers): 140 (2.33 mi/min) + double mileage = 2.33 * time; //diesel + if (fuelType == "electricity") { + mileage += mileage * 0.45; //~200 + } + else if (myEngineSize == "grande"){ + mileage += mileage * 0.1; //10% increase for largest engine + } + return floor(mileage); +} + +string Train::toString() { + return "-> Train\n" + PoweredVehicle::toString() + "\n\tEngine Size: " + + getEngineSize(); +} + diff --git a/Train.h b/Train.h new file mode 100644 index 00000000..ccdd0179 --- /dev/null +++ b/Train.h @@ -0,0 +1,29 @@ +// +// Conner Flynn (cjf16e) 10/4/19 +// + +#ifndef DRIVINGSIMULATOR_TRAIN_H +#define DRIVINGSIMULATOR_TRAIN_H + +#include "PoweredVehicle.h" + +class Train : public PoweredVehicle { + +private: + string myEngineSize; + +public: + Train(); + + explicit Train(string brand, string model, string fuelType, + string engineSize); + + virtual ~Train(); + string getEngineSize(); + void setEngineSize(string engineSize); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_TRAIN_H \ No newline at end of file From 4536ee932be92b1a50d4b35725c95d1d3b13c4c7 Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Fri, 4 Oct 2019 11:57:04 -0400 Subject: [PATCH 11/13] Main test cases updated (2 per class) --- Jet.cpp | 12 ++++++------ Skateboard.cpp | 3 ++- main.cpp | 13 +++++++++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Jet.cpp b/Jet.cpp index 6b0ee80f..9ccd5ca0 100644 --- a/Jet.cpp +++ b/Jet.cpp @@ -10,9 +10,9 @@ // #include Jet::Jet() { - setFuelType("unknown"); - setBrand("custom"); //XOJET - setModel("custom"); //Bombardier + setFuelType("Rocket"); + setBrand("XOJET"); + setModel("Bombardier"); } Jet::Jet(string brand, string model, string fuelType, int numberOfEngines){ @@ -39,13 +39,13 @@ void Jet::setNumberOfEngines(int engines) { double Jet::mileageEstimate(double time) { // srand(time(0)); // int max = 100; - // int min = 40; - + // int min = 40; // double mileage = (min + (rand() % (max - min + 1 ))) * time; - random_device rd; + random_device rd; //g++ -std=c++11 mt19937 gen(rd()); uniform_int_distribution<> dis(40, 100); + //https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution double mileage = dis(gen) * time; if (numberOfEngines > 2 && fuelType == "Rocket") { diff --git a/Skateboard.cpp b/Skateboard.cpp index b7ea8a1e..ef3b7277 100644 --- a/Skateboard.cpp +++ b/Skateboard.cpp @@ -14,9 +14,10 @@ Skateboard::Skateboard(string brand, string model) { Skateboard::~Skateboard() = default; double Skateboard::mileageEstimate(double time) { - random_device rd; + random_device rd; //g++ -std=c++11 mt19937 gen(rd()); uniform_real_distribution dis(0.1, 0.5); + //https://stackoverflow.com/questions/19652657/c-create-a-random-decimal-between-0-1-and-10 double mileage = dis(gen) * time; if (time > 25 && time < 250) { diff --git a/main.cpp b/main.cpp index ba0b6928..6032f364 100644 --- a/main.cpp +++ b/main.cpp @@ -1,13 +1,16 @@ #include #include "Car.h" #include "Bicycle.h" +#include "Jet.h" +#include "Skateboard.h" +#include "Train.h" void printVehiclesRoster(Vehicle **vehicles, int size); int main() { std::cout << "Driving simulator" << std::endl; - int size = 6; - int capacity = 10; + int size = 12; + int capacity = 13; Vehicle **vehiclesArray = new Vehicle *[capacity]; vehiclesArray[0] = new Car(); @@ -16,6 +19,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(); + vehiclesArray[7] = new Jet("Lilium","SU-30","Rocket",3); + vehiclesArray[8] = new Skateboard(); + vehiclesArray[9] = new Skateboard("Santa Cruz","Nickel Fade"); + vehiclesArray[10] = new Train(); + vehiclesArray[11] = new Train("Katiland","AC6000CW","diesel","medium"); printVehiclesRoster(vehiclesArray, size); From 3938657aa0dceefaa6773ae6577589c21e1d71b8 Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Fri, 4 Oct 2019 12:06:50 -0400 Subject: [PATCH 12/13] Empty answers.txt added and committed --- docs/answers.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/answers.txt diff --git a/docs/answers.txt b/docs/answers.txt new file mode 100644 index 00000000..4ac26f8b --- /dev/null +++ b/docs/answers.txt @@ -0,0 +1 @@ +//answers From 62396f11bd050e32bd4a3cd0846b4dec1f22a92c Mon Sep 17 00:00:00 2001 From: cflynn0 <55844079+cflynn0@users.noreply.github.com> Date: Fri, 4 Oct 2019 13:32:36 -0400 Subject: [PATCH 13/13] Finished re-writing answers.txt --- docs/answers.txt | 84 +++++++++++++++++++++++++++++++++++++++++++++++- docs/status.txt | 9 ++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 docs/status.txt diff --git a/docs/answers.txt b/docs/answers.txt index 4ac26f8b..cd40023e 100644 --- a/docs/answers.txt +++ b/docs/answers.txt @@ -1 +1,83 @@ -//answers +// +// Conner Flynn (cjf16e) 10/4/18 +// + +(a) +$ git push --all +Enumerating objects: 23, done. +Counting objects: 100% (23/23), done. +Delta compression using up to 4 threads +Compressing objects: 100% (17/17), done. +Writing objects: 100% (17/17), 3.71 KiB | 180.00 KiB/s, done. +Total 17 (delta 8), reused 0 (delta 0) +remote: Resolving deltas: 100% (8/8), completed with 3 local objects. +To https://github.com/cflynn0/assignment2.git + 347fce8..4536ee9 development -> development + +(b) +18 commits +(It should be 9, but my original answers.txt was left on another machine I could not access before the deadline) +"git rev-list --all --count" +"git shortlog" breaks down commits by user + +(c) +ll -a + ... +-rw-r--r-- 1 CF 197121 45 Oct 3 09:56 .gitignore + +(d) +Branches are used in Git repositories to enable the development of multiple projects using the same source code at the same time. +Branches also preserve the state of the primary branch and external changes do not affect development branches unless those changes +are pulled by the user. + +(e) +While git log displays a history of commits made including author, date, and commit message, git status inspects the current directory +and lists the current branch, whether it's up to date, and which files are staged, unstaged, and untracked. + +(f) +git log --follow -- Vehicle.h + +(g) +git log --all --grep='file' + +(h) + (I) + Inheritance is a mechanism by which objects "inherit" certain properties from another object, for example a child class might inherit + certain properties such as functions or variables from a parent class. + + (II) + Polymorphism is the ability of a single function or class to process objects based on their data type, for example overloading a + single function allows it to be used by objects of various data types. + + (III) + Encapsulation is hiding or restricting the use of data, functions, or other elements from external use. Examples would be private or + protected data in class definitions. + +(i) +While both the “Dictator and Lieutenants” and the “Integration Manager” workflows separate degrees of development with a manager/dictator +reviewing all the changes made by individual developers on individual branches, the difference lies in the public and private repositories +the developers use in the "Integration Manager” workflow. This allows developers to privately develop, then push to their public repository +to be reviewed by the integration manager as opposed to sending their code to "lieutenants" to be reviewed. + +(j) +A team of 100 developers would benefit from following the “Dictator and Lieutenants” workflow instead of the “Centralized” workflow because +using the Centralized workflow requires that each developer pull any changes in the central repository AND resolve conflicts before pushing +their work to the central repository. If 100 people are making changes at the same time, it would be nearly impossible for separate developers +resolve all of these changes. The Dictator and lieutenants workflow allows for organized, chain-of-command development wherein all changes are +reviewed at each level of command before they are resolved and merged by the dictator. + +(OOP Principles) +The Driving simulator prototype is using both polymorphism and encapsulation. Polymorphism is occurring because there is a hierarchy of classes +where each class IS a type of the parent class, i.e. a Car is a type of Powered Vehicle and a Skateboard is a type of Vehicle. The "virtual" function +allows for this prototype to use polymorphism. Encapsulation is occurring because some of the classes have private member data which cannot be +accessed outside the class itself. The Car class's private variable myEngineSize and the Bicycle class's private variable myGearCount are examples +of hidden/restricted data. + + +Citations: +https://stackoverflow.com/questions/7124914/how-to-search-a-git-repository-by-commit-message +https://www.atlassian.com/git/tutorials/inspecting-a-repository +https://beginnersbook.com/2013/03/oops-in-java-encapsulation-inheritance-polymorphism-abstraction/ +https://beginnersbook.com/2017/09/cpp-encapsulation/ +https://www.tutorialspoint.com/cplusplus/cpp_polymorphism.htm + diff --git a/docs/status.txt b/docs/status.txt new file mode 100644 index 00000000..56b801fa --- /dev/null +++ b/docs/status.txt @@ -0,0 +1,9 @@ +On branch development +Your branch is ahead of 'origin/development' by 4 commits. + (use "git push" to publish your local commits) + +Untracked files: + (use "git add ..." to include in what will be committed) + ./ + +nothing added to commit but untracked files present (use "git add" to track)