diff --git a/Helicopter.cpp b/Helicopter.cpp new file mode 100644 index 00000000..91e8f323 --- /dev/null +++ b/Helicopter.cpp @@ -0,0 +1,43 @@ +// +// Created by Emilio Faim +// + +#include "Helicopter.h" + +Helicopter::Helicopter() { + myEngineSize = 1; + setBrand("Custom"); + setModel("VTx"); +} + +Helicopter::Helicopter(string brand, string model, int engineSize) { + setBrand(brand); + setModel(model); + setEngineSize(engineSize); +} + +Helicopter::~Helicopter() = default; + +int Helicopter::getEngineSize() { + return myEngineSize; +} + +void Helicopter::setEngineSize(int size) { + myEngineSize = size; +} + +double Helicopter::mileageEstimate(double time) { + int range = (95 - 20) + 1; + int random = range * (rand() / (RAND_MAX + 1.0)); + double mileage = random * time; + + if (myEngineSize > 1) { + mileage = mileage * (myEngineSize * (0.5)); + } + return mileage; +} + +string Helicopter::toString() { + return "-> Helicopter\n" + PoweredVehicle::toString() + "\n\tEngine Size: " + + Helicopter::getEngineSize(); +} diff --git a/Helicopter.h b/Helicopter.h new file mode 100644 index 00000000..73854369 --- /dev/null +++ b/Helicopter.h @@ -0,0 +1,29 @@ +// +// Created by Emilio Faim +// +#ifndef DRIVINGSIMULATOR_HELICOPTER_H +#define DRIVINGSIMULATOR_HELICOPTER_H +#include +#include "PoweredVehicle.h" + +class Helicopter : public PoweredVehicle { + +private: + int myEngineSize; + + +public: + Helicopter(); + + explicit Helicopter(string brand, string model, + int engineSize = 1); + + virtual ~Helicopter(); + int getEngineSize(); + void setEngineSize(int size); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_Helicopter_H diff --git a/Jet.cpp b/Jet.cpp new file mode 100644 index 00000000..d145ec79 --- /dev/null +++ b/Jet.cpp @@ -0,0 +1,51 @@ +// +// Created by Emilio Faim +// + +#include "Jet.h" + +Jet::Jet() { + myEngineSize = "unknown"; + setBrand("Custom"); + setModel("VTx"); + numberOfEngines = 1; +} + +Jet::Jet(string brand, string model, string fuelType, string engineSize, int numberOfEngines) { + setBrand(brand); + setModel(model); + setFuelType(fuelType); + setEngineSize(engineSize); +} + +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) { + int range = (100 - 40) + 1; + int random = range * (rand() / (RAND_MAX + 1.0)); + + double mileage = random * time; + if (fuelType == "Rocket" && numberOfEngines >= 2) { + mileage = mileage * (numberOfEngines*(0.055)); + } + return mileage; +} + +string Jet::toString() { + return "-> Jet\n" + PoweredVehicle::toString() + "\n\tEngine Size: " + + getEngineSize(); +} diff --git a/Jet.h b/Jet.h new file mode 100644 index 00000000..d9a09426 --- /dev/null +++ b/Jet.h @@ -0,0 +1,29 @@ +// +// Created by Emilio Faim +// +#ifndef DRIVINGSIMULATOR_JET_H +#define DRIVINGSIMULATOR_JET_H +#include +#include "PoweredVehicle.h" + +class Jet : public PoweredVehicle { + +private: + string myEngineSize; + int numberOfEngines = 1; + +public: + Jet(); + + explicit Jet(string brand, string model, string fuelType, + string engineSize, int numberOfEngines = 1); + + virtual ~Jet(); + string getEngineSize(); + void setEngineSize(string engineSize); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_JET_H diff --git a/README.md b/README.md index e69de29b..c3392e97 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,4 @@ +Name: Emilio Faim +FSUID: ejf15b + + diff --git a/Skateboard.cpp b/Skateboard.cpp new file mode 100644 index 00000000..a02e8c8b --- /dev/null +++ b/Skateboard.cpp @@ -0,0 +1,38 @@ +// +// Created by Emilio Faim. +// + +#include "Skateboard.h" + + +Skateboard::Skateboard(string brand, string model, int min) { + setBrand(brand); + setModel(model); + setMinutes(min); +} + +Skateboard::~Skateboard() = default; + +int Skateboard::getMinutes(){ + return minutes; +} + +void Skateboard::setMinutes(int min){ + minutes = min; +} + +double Skateboard::mileageEstimate(double time) { + double range = (0.5 - 0.1) + 1; + double mileage = range * ((double)rand() / (RAND_MAX + 1.0)); + if (minutes > 25 && minutes <= 250){ + int range2 = (minutes/3 - 1) + 1; + mileage = range2 * (rand() / (RAND_MAX + 1.0)); + } + return mileage; +} + +string Skateboard::toString() { + string s = "-> Skateboard\n\t"; + return "-> Skateboard\n" + Vehicle::toString() + "\n\tMinutes: " + + to_string(minutes); +} diff --git a/Skateboard.h b/Skateboard.h new file mode 100644 index 00000000..237d03d2 --- /dev/null +++ b/Skateboard.h @@ -0,0 +1,27 @@ +// +// Created by Emilio Faim. +// + +#ifndef DRIVINGSIMULATOR_SKATEBOARD_H +#define DRIVINGSIMULATOR_SKATEBOARD_H +#include +#include "Vehicle.h" + +class Skateboard : public Vehicle { + +private: + int minutes; + +public: + explicit Skateboard(string brand, string model, int min); + + virtual ~Skateboard(); + int getMinutes(); + void setMinutes(int min); + virtual double mileageEstimate(double time); + + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_Skateboard_H diff --git a/Vehicle.h.gch b/Vehicle.h.gch new file mode 100644 index 00000000..ff514db7 Binary files /dev/null and b/Vehicle.h.gch differ diff --git a/docs/answers.txt b/docs/answers.txt new file mode 100644 index 00000000..38f5d2fe --- /dev/null +++ b/docs/answers.txt @@ -0,0 +1,102 @@ +//Answers.txt + +(a) Paste the console output you saved at the end of step 3.C (2 points) + +(base) wc-dhcp201d240:assignment2 emiliofaim$ git status +On branch master +Your branch is up to date with 'origin/master'. + +nothing to commit, working tree clean + + + +(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) + +(base) wc-dhcp201d240:docs emiliofaim$ git rev-list --all --count +9 + + + +(c) When was the .gitignore file modified last? Write the git command you used to get this information (4 points) + +Last time modified was september 25 by Esteban Parra, and the command I used to find out was: +"git log .gitignore" + +Sample output: + +(base) wc-dhcp201d240:assignment2 emiliofaim$ git log .gitignore +commit e424a923e80da4772ca789591ef3326230062a71 +Author: Esteban Parra +Date: Wed Sep 25 18:13:30 2019 -0400 + + -> Tracking .gitignore + + + +(d) Mention two reasons why branches are used in a Git repository (4 points) + +1. Branches are used to organize and make the workflow more efficient and effortless + +2. it will let teams work in parallel and at the same time + + + +(e) What is the difference between git log and git status? (4 points) + +The gig log command as it is stated on its documentation shows the commit logs of the file. + +The git status command is described also in its documentation, it will show the status of the working three, +not only the file . + + + +(f) What command would you use to see the commits where “Vehicle.h” was one of the committed files? (4 points) + +git log --follow Vehicle.h + + + +(g) What command would you use to see the commits whose commit message contains the word “file”? (4 points) + +git 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: It is a mechanism where you can to derive a class from another class that share a set +of attributes and methods + +II) Polymorphism: When you override the method inherited from the supper class and then you modify it depending +on the needs + +III) Encapsulation: the idea of bundling data and methods in order to be used inside of that unit. for example: classes + +Read the “Git Commands, workflow, and resources.pdf” file on Canvas and answer the following questions: +(i) What is the main difference between the “Dictator and Lieutenants” workflow and the “Integration manager” workflow? (5 points) + +Dictator and Lieutenants: + Distributed development and integration. + central repository + merges changes in the lieutenants repos and solve the problems + Lieutenants repos: merge some changes and solves errors + +Integration manager: + each developer makes their own push and all o the pull from the same repository + integration conflict resolution are done by the integration manager + Each developer makes pull and push to his/her own public repository + + +(j) How would a team of 100 developers benefit from following the “Dictator and Lieutenants” workflow instead of the “Centralized” workflow? (5 points) + +A group with a big amount of developers can be benefited from the dictator workflow because all the push pass by +one person the dictatir who have the responsability of checking the work and make sure the quality of the code. + + +PART 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. + +In the Driving Simulator we could appreciate the use of encapsulation as I explained before, we used classes in order to use the data available only +for those classes and those methods that are encapsulated inside of them. and we did not override any class in order to apply polymorphism. diff --git a/docs/status.txt b/docs/status.txt new file mode 100644 index 00000000..c9bfc23c --- /dev/null +++ b/docs/status.txt @@ -0,0 +1,6 @@ +//status.txt file + +On branch master +Your branch is up to date with 'origin/master'. + +nothing to commit, working tree clean diff --git a/docs/temp_files.txt b/docs/temp_files.txt new file mode 100644 index 00000000..3ff3741c --- /dev/null +++ b/docs/temp_files.txt @@ -0,0 +1,16 @@ +//temporary output +//first status check +(base) wc-dhcp201d240:assignment2 emiliofaim$ git status +On branch master +Your branch is up to date with 'origin/master'. + +Untracked files: + (use "git add ..." to include in what will be committed) + + docs/ +//second status check +(base) wc-dhcp201d240:assignment2 emiliofaim$ git status +On branch master +Your branch is up to date with 'origin/master'. + +nothing to commit, working tree clean diff --git a/main.cpp b/main.cpp index ba0b6928..9469cc28 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,8 @@ #include #include "Car.h" #include "Bicycle.h" +#include "Skateboard.h" +#include "Jet.h" void printVehiclesRoster(Vehicle **vehicles, int size); @@ -16,6 +18,7 @@ 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(); 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 +}